- Home /
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!
Have you tryed a smooth follow camera script that unity comes with?
Yes, I tried SmoothFollow2D (my camera orientation doesn't change), and it doesn't work.
You can see the jittering effect in the latest online build : http://light-and-shadows.net/Unity/Chameleon/
Heya, any luck on solving this?
I'm having exactly the same problem. The rigidbody is set to interpolate, so its transform.position component should be silky smooth. I discovered however that it's not! Just plain old printing its position to the log window shows many times where it has exactly the same value for 2 whole frames, no matter which combination of Updates you try.
I'll be trying manual interpolation next, hope that works out.
I switched to fixed framerate, it's far from perfect, but it's better.
Your solutions to change to a fixed framerate helps a lot. $$anonymous$$aybe it's just a hot fix but works really good. Thank you, even if this helps me 8 years later:))
Answer by blade_sk · Mar 20, 2019 at 11:57 AM
You're probably looking for this https://docs.unity3d.com/ScriptReference/Rigidbody-interpolation.html
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.
This solved the issue for me. I had a camera following a transform nested under an obect with a rigidbody.
This is exactly what I have needed for a long time, moving my camera into FixedUpdate made the player smooth but the environment became jittery, which looks much worse. With this, both are perfectly smooth, thanks!
Answer by maxrevilo · Jul 10, 2016 at 05:18 PM
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.
Answer by cerealwrath · Jun 07, 2011 at 10:44 PM
There are several possible solutions for this issue.
Attach the "Smooth Follow" script that comes in Standard Assets to your camera.
Confirm that your character is not inside or touching the ground/terrain, even partially.
Edit the Gravity variable and lower it to something around 8 or 10. (This will also reduce your fall speed.)
I tried the SmoothFollow2D, and it doesn't work. $$anonymous$$y character is not touching anything I cannot change the gravity settings or the scale of the scene, and it should not be required, it's not moving very fast. I mean, the speed clearly impact the jittering, but even at low speed it's visible.
Answer by wolfstien786 · Jul 28, 2012 at 02:32 PM
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)
This will make every other object that is not physically based jittery.
Answer by Taphos · Feb 01, 2016 at 02:18 PM
Check my answer in this thread: http://forum.unity3d.com/threads/camera-following-rigidbody.171343/#post-2491001