syncing 2D physics with framerate

Hi

I have a 2D playerobject a rigidBody2D and forces to move it around.

Since I need a physics update exactly once per frame for smooth motion, I set Time.fixedDeltaTime = 1f/Application.targetFrameRate;

I’ve done that on previous projects and it worked fine.

However this one, every few seconds the object skips, as if it’s dropping a frame, even though the game is running at a solid 60 fps.

This happens even on my PC which can easily render the game at 4/500 fps, and on Android and ios.

Thanks

It’s not clear what you’re asking for here. You can set the simulation mode to be per-frame (variable simulation rate) in the Physics 2D Settings. Obviously this means you have to ensure your frame-rate doesn’t get too low otherwise you’ll get a progressively poorer simulation.

You can also continue to use a fixed-rate simulation (the default) and simply use interpolation on the Rigidbody2D so the visuals are interpolated from previous to current pose.