Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Ostinyo · Jul 18, 2013 at 08:22 PM · javascriptcharactercontrollersliding

Unslide does not revert back to normal

I know that a lot of questions alike to this have already been asked, but my problem is that when the player stops sliding, the character controller either (A) grows to a size less than the original, or (B) falls through the floor (because the bounds of the controller's collision pass through the ground). Here is my code:

 if (isSliding)
     {
     tempCenter.y = controller.height/4;
     controller.center.y = tempCenter.y;
     //controller.center.y = 0.25;
     controller.height = 0.5; // height is slide height
     moveDirection.z = 2.0; // speed is slide speed
     controller.Move(moveDirection * Time.deltaTime);
 
     slideTimer += Time.deltaTime;
     if (slideTimer > slideTimerMax) //stop sliding (part I need help with)
     {
         isSliding = false;
         moveDirection.z = 3.0; //speed is normal
         transform.position.y += 10;
         controller.center = Vector3(transform.position.x,0.5,transform.position.z);
         //tempCenter.y = controller.height/4;
         //controller.center.y += 5.0;
         //controller.center.y = tempCenter.y;
         controller.height = 1.0;
     }
 }
 if (!isSliding)
 {
     speed = 3.0;
     controller.Move(moveDirection * Time.deltaTime);
 }

All of the lines of code that were commented out are different approaches I have tried to use. No matter what value I set (high/low, pos/neg, mult/div) I always end up with a smaller position on the y axis than what I started with. Help would be greatly appreciated as I cannot figure out how to solve the problem.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ostinyo · Jul 18, 2013 at 08:40 PM

I seem to have fixed the problem. The main thing was that the force of gravity on my character controller was too great. I ended up not changing the center of the character controller at all, but instead using transform.position.y += 1.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Struggling with jumping! 3 Answers

Collision Detection 0 Answers

Increasing Camera "Bobbing" speed when character is sprinting 1 Answer

How to fix? Character grabbing system 1 Answer

how to take maya animation file in to unity? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges