Implement your own physics world by extending this class
Constructor
Variables
updateRate:Int = 50
For a consistant and performant physics simulation, a fixed rate is used always regardless of framerate. This is 50hz by default, but you can change it if you need it.
Note: Setting this value above the game framerate will cause physics updates to be called more than once per frame, it's better to keep this value under 100 ticks per second and use physics interpolation instead.
timeStep:Float = 1 / 50
This is the time passed between each physics step, this can be used to slow down or speed up the simulation while updating it at the same rate.
subSteps:UInt = 4
This is the amount of physics update ocurring between frames for accurate collision detection, a value of 4 is decent enough, but it can be increased or decreased for a tradeoff between accuracy and speed.
Too low of a value can cause high-speed objects to go trough other objects or cause jittering.
onPhysicsUpdate:(dt:Float) ‑> Void
A function to call alongside world_Step
Used in FoxScene to call member's physicsUpdate()
Methods
step(dt:Float):UInt
Steps the physics simulation.
Internally, this has a delta counter so updates happen at a fixed rate.
If the application update rate is lower than updateRate, more calls
will happen per frame.
Parameters:
dt | The actual elapsed time for the application |
|---|
Returns:
The number of iteration steps needed for compensation. Can be 0, meaning no step is required this frame