Skip to main content

Physics.Simulate(number step)

Simulate physics in the Scene.

Parameters:

NameTypeDescription
stepnumberThe time to advance physics by.

Usage

---@type number
local step;


Physics:Simulate(step)

Extra Detail

Call this to simulate physics manually when the automatic simulation is turned off. Simulation includes all the stages of collision detection, rigidbody and joints integration, and filing of the physics callbacks (contact, trigger and joints). Calling Physics.Simulate does not cause FixedUpdate to be called. MonoBehaviour.FixedUpdate will still be called at the rate defined by Time.fixedDeltaTime whether automatic simulation is on or off, and regardless of when you call Physics.Simulate.

Note that if you pass framerate-dependent step values (such as Time.deltaTime) to the physics engine, your simulation will be non-deterministic because of the unpredictable fluctuations in framerate that can arise.

To achieve deterministic physics results, you should pass a fixed step value to Physics.Simulate every time you call it. Usually, step should be a small positive number. Using step values greater than 0.03 is likely to produce inaccurate results.