Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 thenephalem · Dec 31, 2017 at 03:40 PM · unity 5rigidbodyfixedupdatecamera movementjitter

Camera jitters / lag behind when jumping or falling

I know that there have been numerous threads about this topic but still i find it difficult to comprehend the whole situation. I update the rigidbody's velocity in the horizontal direction in FixedUpdate() and then I apply force (my own gravity) in the vertical direction also in the FixedUpdate() method. In the CameraController script I use the following lines to update the position of the camera.

toPos = currentView.position + (currentView.rotation * new Vector3(0f, 2f, -2.5f));
curPos = Vector3.Slerp(transform.position, toPos, smoothFactor * Time.deltaTime); And then I have in the LateUpdate()
transform.position = curPos;
transform.LookAt(currentView.transform, currentView.transform.up);

The result is quite smooth when running on a platform (no gravity) but the camera begins to jitter when I jump or the player is falling. I have spent too many hours on this problem and I will be really grateful if someone is able to explain to me how to fix this issue.

Best regards Your friendly neighbourhood noob

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

2 Replies

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

Answer by meat5000 · Jan 02, 2018 at 01:21 PM

It is usually inadvisable to directly modify velocity. It can make for some erratic behaviour. Jitter usually arises from differences of updates between FixedUpdate and Update. Timing of FixedUpdate is not really as Fixed as it may suggest and sometimes placing code in Update instead produces better results, creating better scaling of variables with respect to how the User views it from frame to frame.

Movement by direct Transform modification can also create some jittery results. A combination of the two could be asking for trouble. The results will be worsened at lower fps.


The reason why your character jitters in vertical whilst horizontal Velocity is being set is that Spamming a velocity component to 0f will cause that object to stop dead in that direction and then regain speed under the Physics Engines computational updates. This is why a lot of people end up with Player-characters that float like clouds when jumping.


When setting Velocity, make sure to first read off the Current Velocity x,y,z values and use those as a base for your next calculation, adding or subtracting a scaled amount, instead of hard setting values. This serves to add some (de)/(a)cceleration.

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 thenephalem · Jan 17, 2018 at 10:43 AM 0
Share

playerRigidBody.$$anonymous$$ovePosition(transform.position + myForward Time.deltaTime currentSpeed);

playerRigidBody.AddForce(-gravity myGravity playerRigidBody.mass);

playerRigidBody.AddForce(myGravity jumpForce jumpHeight, Force$$anonymous$$ode.Impulse);

All of those are in FixedUpdate and I follow my player in FixedUpdate but in the camera script. How do you suggest to modify them so that I get better results? Thank you for the previous answer I had some problems and I did not have enough time to continue on my game but now I am on track.

avatar image
4

Answer by thenephalem · Jan 02, 2018 at 12:03 PM

I have finally found the problem. It was that my rigidbody's Interpolate was set to Interpolate. I have changed it to None and all of the jitter/stutter when falling or jumping is now gone. I will definitely make further research on this topic. If anybody has any idea why this happens it would be wonderful. I make all of my physics in FixedUpdate.

Comment
Add comment · Show 2 · 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 DK_Programmer · Apr 01, 2019 at 11:36 PM 0
Share

Wow thanks, that did the trick.

avatar image ChunkyToads · Apr 04, 2020 at 12:35 AM 0
Share

Grinding my brain on this for a while today. Shutting off "Interpolate:" was the trick. THANKS for pushing forward @thenephalem. $$anonymous$$uch appreciated.

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

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

Related Questions

Move a camera with Rigidbody velocity without jitter 1 Answer

How can I avoid jitter of house? 0 Answers

How to prevent camera jitter when moving my Rigidbody first person controller 4 Answers

Game not running properly on slow machines (low fps) 1 Answer

How can I pragmatically move a navmesh rigid body when changing scenes? 0 Answers


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