Skip to main content
Methods for controlling the simulation lifecycle and timing. Access via ref on MujocoCanvas or useMujoco().api inside R3F.

reset()

Reset the simulation to its initial state.
Applies homeJoints from the scene config (if set), runs mj_forward, and calls the onReset callback.

setPaused(paused)

Pause or resume the simulation.
boolean
required
Whether the simulation should be paused.

togglePause()

Toggle pause state. Returns the new paused state.
Returns: boolean — the new paused state.

step(n?)

Advance the simulation by n steps while paused.
number
default:"1"
Number of physics steps to advance.
Has no effect if the simulation is not paused.

setSpeed(multiplier)

Set the simulation speed multiplier.
number
required
Speed multiplier. 1.0 = real-time, 0.5 = half speed, 2.0 = double speed.

getTime()

Get the current simulation time in seconds.
Returns: number — simulation time in seconds.

getTimestep()

Get the current simulation timestep.
Returns: number — timestep in seconds.