R3d.World:step

From GiderosMobile
Revision as of 14:30, 13 July 2023 by Hgy29 (talk | contribs) (Text replacement - "<source" to "<syntaxhighlight")

Available since: Gideros 2019.10
Class: R3d.World

Description

The DynamicsWorld is used to simulate physics through time. It has to be updated each time you want to simulate a step forward in time. Most of the time, you want to update the world right before rendering a new frame in a real-time application.

This method will perform collision detection and update the position and orientation of the bodies and joints. After updating the world, you will be able to get the new position and orientation of your bodies for the next frame to render. <syntaxhighlight lang="lua"> r3d.World:step(time) </source>

Parameters

time: (number) the amount of time you want to advance the physics simulation (in seconds)

Example

<syntaxhighlight lang="lua"> stage:addEventListener(Event.ENTER_FRAME, function(e) world:step(e.deltaTime) end) </source>

If you want to know more about physics simulation time interpolation, you can read the nice article from Glenn Fiedler at https://gafferongames.com/post/fix_your_timestep/.