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
1
Question by Musty · Dec 11, 2013 at 05:06 PM · charactercontrollercharacter.move

Character controller is shaky/jittery

Hey Guys, Im using the code below to make the character move. It automatically jumps when it lands on platforms but it shakes/jitters specially when the player is going down and i cant work out why.. The character is a cube and doesnt have any extra colliders besides character controller.

 void Start ()
     {
         control = GetComponent<CharacterController>();
     
     }
     
     // Update is called once per frame
     void Update ()
     {    
         distanceTraveled = transform.localPosition.x;
         score +=  Time.deltaTime  * 20;
         move = new Vector3 (Input.GetAxis("Horizontal"),0f,0f);
         move *= playerSpeed;
 
         
         if(Input.GetKey(KeyCode.LeftArrow))
         {
 
             transform.forward = new Vector3(0f, 0f, -1f);
         }
         
         if(Input.GetKey(KeyCode.RightArrow))
         {
 
             transform.forward = new Vector3(0f, 0f, 1f);
         }
         
         if (!control.isGrounded)
         {
             gravity  += Physics.gravity * fallSpeed * Time.deltaTime;
         }
         else
         {
             gravity = Vector3.zero;
             gravity.y = jumpSpeed;
         }
         
         move += gravity;
         
         control.Move(move * Time.deltaTime);
 
     
     }
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 AeonIxion · Dec 11, 2013 at 06:45 PM

http://answers.unity3d.com/questions/8207/charactercontroller-falls-through-or-slips-off-mov.html

The answers there will probably help you with the jittering problem. I'd personally go for Codayus' solution.

As for your character jumping when it hits a platform..At line 35 you're setting the y value of your gravity to the jumpspeed every time the controller (player) is grounded. I think you only want this to happen when the user presses a button?

Comment
Add comment · Show 1 · 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
avatar image Musty · Dec 12, 2013 at 07:29 PM 0
Share

Thanks ill check it out, the reason it's auto jumping is because it's landing on a trampoline type thing

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

17 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 avatar image avatar image

Related Questions

How to "add force" to a character controller 1 Answer

CharacterController.Move problem with pause menu 2 Answers

hi, how to give controls to a 3d character model. i have downloaded the model as .fbx file 0 Answers

charactercontroller.Move Jump not working! 2 Answers

Character Controller Script Increasing characters Y position 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