CurryKitten / CurryKitten-Sim

FPV quad simulator
70 stars 7 forks source link

Fix object jitter #21

Closed CurryKitten closed 4 years ago

CurryKitten commented 4 years ago

After fixing this issues with the shadows jittering in #1 the jitter in objects has become more noticable. This is especially noticeable when rotating around an object - i.e a racing gate. I'd first thought this might be down to my old iMac unable to keep up with the frame rate, but I've just replaced with a new and very powerful system and it's still there.

This seemed odd as the entire game loop is running very quickly >60fps. It's infact this speed which is the problem. Further investigation tells me that the physics run in a fixed timing interval (FixedUpdate in Unity language) but that the Update loop where most of the logic happens will run as fast as the system can go. This can result in certain elements of the game getting updates at different times which causes object to look as it they are jittering as the physics loop and graphics loop go out of time. The method of fixing this is a combination of interpolation and choosing carefully where any camera/objects moves go in terms of timing loops

CurryKitten commented 4 years ago

Fixed this, it'll be in the 04a release. Weirdly, the problem here was the fact that interpolation was on for the quad rigidbody component which should have been smoothing stuff, but was having the opposite effect. I did move the remaining transformations into the FixedUpdate loop as well though. It's now looking nice and smooth