• 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 mlovrekov · Oct 02, 2020 at 11:08 AM · charactercontrollerjumpjitter

Charactercontroller jittering while jumping into wall

I've got an entity with a CharacterController component. Everyt$$anonymous$$ng is set to default aside from the capsule positioning. I've also added a separate ground check (using Physics.CheckSphere) and I've gotten my character to move around and jump. T$$anonymous$$s is the code executing in character's movement FixedUpdate script

  void FixedUpdate()
     {        
         if (velocity.x != 0 || velocity.z != 0)
         {            
             transform.Rotate(Vector3.up * rotationAngle);
                         
             Vector3 forwardMovement = transform.forward * velocity.z;
             Vector3 rightMovement = transform.right * velocity.x;            
 
             Vector3 movement = forwardMovement + rightMovement;
 
             controller.Move(movement * Time.deltaTime);            
         }
 
         if (groundCheck.IsGrounded && velocity.y < 0f)
         {
             velocity.y = -0.2f;
         }
 
         velocity.y += Physics.gravity.y * Time.deltaTime;
         controller.Move(Vector3.up * velocity.y * Time.deltaTime);
     }

And t$$anonymous$$s is the code executed on keypresses (coded as actions run wit$$anonymous$$n a Update)

 private void OnMovementAxes(Vector2 axes)
     {        
         if (axes == Vector2.zero)
         {
             velocity.x = 0f;
             velocity.z = 0f;
             return;
         }
 
         Vector2 newVelocity = axes.normalized * movementSpeed;
         velocity.x = newVelocity.x;
         velocity.z = newVelocity.y;
     }
 
     private void OnJumpPressed()
     {        
         if (controller.isGrounded)
         {
             velocity.y = Mathf.Sqrt(jumpHeight * -2f * Physics.gravity.y);
         }        
     }    
 
     private void OnCameraPosition(Vector3 cameraPosition, Vector3 cameraDirection)
     {        
         Debug.DrawRay(cameraPosition, cameraDirection * 10, Color.red);
         Vector3 movementDirection = Vector3.Scale(cameraDirection, Vector3.right + Vector3.forward);
         Debug.DrawRay(cameraPosition, movementDirection * 10, Color.blue);
 
         rotationAngle = Vector3.Angle(transform.forward, movementDirection);
 
         float crossProduct = Vector3.Cross(transform.forward, movementDirection).y;
 
         if (crossProduct < 0)
         {
             rotationAngle *= -1;
         }
     }

When my character reaches a wall that they should be able to jump onto (and they can if they jump from a bit further back), and tries jumping w$$anonymous$$le holding forward movement, the character does lift but not even half the jump height it usually does, and it just jitters.

First I assumed that the GroundCheck sphere is too large so that the front of it is touc$$anonymous$$ng the wall and registering as "grounded" when colliding with the wall so I made it small enough that it's well enough be$$anonymous$$nd the main capsule collider. Didn't help

Then I played with Skin WIdth property. Tried setting it from 0.08 to 0.1, 0.5 and even 1 (w$$anonymous$$ch was interesting to see) but that didn't help either.

Then I tried changing Slope Limit property from 45 to 90 and that seems to have fixed the issue but I'm not sure why that is. I don't quite know what "Slope Limit" actually does. Does it specify how steep a slope the character can "climb" up? Also that solution seems like a bit of a hack.

Is there a better solution to prevent t$$anonymous$$s jitter when trying to jump w$$anonymous$$le running into a wall?

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

Making a character jump with the Character Controller Component instead of Capsule Collider 0 Answers

Sonic trampoline style with character controller(old one) 1 Answer

Jump with Character Controller 1 Answer

[C#] Jump on slopes 1 Answer

Anti-Gravity isn't working 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