- Home /
Are unity's and Physx's frame rates in sync?
Hello, As far as I understand physics engines, they by themselves have a frame rate determined by the variable timestep (which is usually set to 1/60). Unity too its own frame rate determined by the variable Fixed timeStep. My question is this: is unity's frame rate the same as Physx's frame rate? or does physics simulation in unity run at a different frame rate than the rest of the simulation?
Answer by Tarlius · Feb 26, 2013 at 06:57 PM
Fixed usually refers to the physics simulation. Unity calls Update() once per real rendered frame, and FixedUpdate() every physics frame (of which there can be more than 1 per "real" frame, or 0). How many FixedUpdates unity does between Updates will depend on the framerate, it should be called a fixed number of times per second, regardless of framerate.
So yes, the framerates will be different, unless you have a perfectly smooth framerate that is the same as simulation (unlikely)
Unity does not have a timestep for the graphics. It will aim for vsync if enabled, a targetframerate if not, or as many fps as it can. You can use Time.deltaTime to find the time between the the start of the current frames and the start of the last frame, though. (note that deltaTime will give you the fixed (physics) interval if used in FixedUpdate)
If I understand this right, this implies that the fixed timestep that unity allows us to modify is the PhysX timestep. Can we access Unity's own frame rate or is that an internal setting?
Tarlius already answered that: "Unity does not have a timestep for the graphics. It will aim for vsync if enabled, a targetframerate [Application.targetFrameRate] if not, or as many fps as it can. You can use Time.deltaTime to find the time between the the start of the current frames and the start of the last frame".