Jittery objects when camera attached to rigidbody

Hello,

My game setup is the following :

  • My character is a rigidbody, all movement code is done with AddForce, in FixedUpdate
  • There is a background that does not move behind character
  • The camera follows the character, the camera updates in LateUpdate

Now using this basic setup, I cannot find a single way to have all my objects not move with some jitter side effects.

I can add some rigidbody.interpolate ( http://unity3d.com/support/documentation/ScriptReference/Rigidbody-interpolation.html ) but the background is still jittery… I tried using many different smoothing methods for the camera, curently using a double damping, but it doesn’t help. I tried moving around the camera update code, and it didn’t help either. I also tried to fix my FPS to 60 (on PC it can run at 500FPS), and set my physics to 60fps as well, but still they are some jitters.

What is the best practice to have a smooth camera movement with no jitters when your character is controlled by physics ?

Thank you for your help!

You’re probably looking for this Unity - Scripting API: Rigidbody.interpolation
135048-2019-03-20-12-55-23.png

Set interpolation of your RigidBody to “interpolate”. It interpolates transforms for the missing frames if your FPS is greater than the update rate of physics.

For me the solution have been to set the Fixed Timestep to 1/FPS, for example if your desired frame rate is 60 FPS then your fixed timestep should be 1/60=0.0166665 or smaller, if you are worried by the performance then you should cap your FPS to 30 or 24 FPS.

There are several possible solutions for this issue.

  1. Attach the “Smooth Follow” script that comes in Standard Assets to your camera.
  2. Confirm that your character is not inside or touching the ground/terrain, even partially.
  3. Edit the Gravity variable and lower it to something around 8 or 10. (This will also reduce your fall speed.)

add a rigidbody component to your camera and move all your follow code into fixed update. Also make sure that other rigidbody codes are in fixed update. Hope this helps :o)

Check my answer in this thread: http://forum.unity3d.com/threads/camera-following-rigidbody.171343/#post-2491001

2 solutions:

  1. Make your camera follow player in FixedUpdate

  2. Or, you can change the Fixed Timestep to 0.01 at:
    Menu > Edit > Project Settings > Time.