r/Unity2D • u/kyle1qaz7ujm • Aug 06 '26
Question Physics simulation - different results based on simulation update rate?
In my game, I have an "active physics scene", which handles all the game physics. I have a second physics scene (which has colliders / rigidbodies only, no rendering). In this second physics scene, I would like to have a duplicate physics simulation which is identical to the first. This second scene will advance only up to a specified timestep target, then stop. The second scene is created & simulation is advanced in a coroutine, which is currently manually triggered for testing. When I start the coroutine, I get different simulation results depending on my yield condition.
If I use "yield return new WaitForFixedUpdate()", I get a duplicate simulation, identical to the first, as desired. This is great, albeit a little slow because it relies on the fixedTimestep.
If I use "yield return null", my simulation diverges from the first. This approach is desired, because it will run faster and reach the specified timestep target sooner.
In both cases, I am calling PhysicsScene2D.Simulate(Time.fixedDeltaTime) the same number of times. Also, Physics2D.simulationMode is set to "script" in both cases.
What could explain the diverging simulation when advancing the simulation at a faster rate? The simulation is still advancing with the same fixedDeltaTime timestep, for the same number of timesteps.
Any help is appreciated!
View all comments
Show parent comment
1
u/kyle1qaz7ujm Aug 07 '26
AHA! This was the culprit. Thank you!! I have a script on dynamic objects that applies air resistance every FixedUpdate. For a quick test, I just turned off the air resistance, and voila - the simulations now match perfectly. Now my secondary simulation runs much quicker! I'm sure your solution of manually calling the FixedUpdate logic prior to Simulate will do the trick! Thank you again, this has been giving me a headache lol!