Hi, I've been trying to make a 3rd person camera for my car game. I used this same principle in the non ECS version and it worked great, but when I started transferring this project into ECS, the camera was jittering. I have figured out it's the smoothing in this very simplified version of the camera controller (I used Vector3.Lerp for the camera position smoothing), and when I don't smooth it's position like that, just follow the car, it doesn't jitter. I'm new to Unity Entities and I would appreciate if anyone knows a solution to this problem.
#Camera following entity is jittering with Smoothing/Lerp
1 messages · Page 1 of 1 (latest)
maybe it's due to a variable framerate making the lerp behave like this?
you can see if it's related if you use frame-rate independent interpolation, like here
https://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
also, in what update did you smooth the camera before and where do you smooth it now?
and where did you put the update of the car itself (that the camera is following)
Well, I'm using the new Unity Vehicles 0.1.1-exp.1 for this. It seems to me that its running in a fixed step count. I'm using LateUpdate for both the old and new camera, so technically its the last thing to update in the frame.
yeah that seems reasonable
my first theory is your framerate is much higher than your physics timestep, and you have a high lerp factor
which will cause jittering because it will lerp a big amount after the fixed update, then have a couple of frames with a small amount of lerp
you may want to adapt your smoothing to the velocity of the thing you follow
e.g. use some kind of interpolation/extrapolation instead of a lerp
or a combination of interpolation and lerp
for example if you do proper interpolation of your car's position in the regular update and follow that instead of the raw physics position, it should already be much smoother (unless im completely wrong of course)
Thanks, I'll definitely be giving that a try later today
I also recommend to use damping instead of lerp as I mentioned initially
It could work better, yeah, but I'm currently trying just to port the old camera from the old project because it worked really good with smoothing