Goodluck / API Reference

sys_physics_integrate

The first step of the physics simulation: integrate the rigid body's acceleration and velocity, and update the entity's transform.

For the physics simulation to work correctly, the following order of systems is recommended.

FrameUpdate(delta: number) {
    // ...

    // Apply acceleration and velocity to position.
    sys_physics_integrate(this, delta);
    // Update transforms.
    sys_transform(this, delta);
    // Detect collisions.
    sys_collide(this, delta);
    // Optionally, derive the velocity of kinematic bodies.
    sys_physics_kinematic(this, delta);
    // Resolve collisions: move colliding bodies apart and swap velocities.
    sys_physics_resolve(this, delta);
    // Update transforms again to account for collision response.
    sys_transform(this, delta);

    // ...
}