AM_RapierPhysics

AM_RapierPhysics

Provides an actor with an interface to the Rapier physics simulation.

Allows you to create a rigid body to track the object's position, and attach colliders to it. An object may only have one rigid body as a time, but can have multiple colliders.

Note: Only kinematic rigid bodies listen for Worldcore movement events. Other types of rigid bodies (static, dynamic) should not have their positions changed after they are created. Static rigid bodies don't move, and the position of dynamic rigid bodies is controlled by the simulation.

Members

# rigidBody

Returns the Rapier rigid body attached to this Wordcore object.

Methods

# createRigidBody(rigidBodyDesc)

Create a new rigid body for this object. Deletes any previous rigid body and its attached colliders. An object can only have one rigid body at a time. The position of the rigid body is taken from the position of the object at the moment that it's created. Takes as its argument a Rapier rigid body description (see the Rapier docs for more information.)

Supported types:

  • Static - Doesn't move
  • Dynamic - Position controlled by simulation
  • KinematicPositionBased - Position controlled by user
Parameters:
Name Type Description
rigidBodyDesc RigidBodyDesc

A Rapier rigid body description.

Example
this.createRigidBody(RAPIER.RigidBodyDesc.newDynamic());

# removeRigidBody()

Deletes the object's current rigid body and any attached colliders. Called automatically when the actor is destroyed.

# createCollider(colliderDesc)

Create a new collider and attaches it to the object's rigid body. Objects can have multiple colliders at the same time. Takes as its argument a Rapier collider description (see the Rapier docs for more information.)

Parameters:
Name Type Description
colliderDesc ColliderDesc
Example
const cd = RAPIER.ColliderDesc.cuboid(0.5, 0.5, 0.5);
cd.setRestitution(0.5);
cd.setFriction(0.8);
cd.setDensity(2.5);
this.createCollider(cd);