dacha
    Preparing search index...

    Class RigidBody

    RigidBody component for defining rigid body physics.

    Defines the physics properties for an actor. Dynamic bodies react to forces, impulses, gravity, collisions, and rotation. Static and kinematic bodies can participate in collisions but are not moved by solver impulses.

    Physics is simulated in world space.

    Rigid bodies may be parented only to actors with static transforms. A moving parent (for example, a dynamic or kinematic rigid body) and the physics simulation would both control the child's transform, so the result is undefined.

    // Create a dynamic rigid body
    const rigidBody = new RigidBody({
    type: 'dynamic',
    mass: 10,
    gravityScale: 1,
    linearDamping: 1,
    disabled: false,
    });

    // Add to actor
    actor.setComponent(rigidBody);

    // Modify properties
    rigidBody.mass = 20;

    Hierarchy (View Summary)

    Index
    _angularImpulse: number

    Angular impulse applied to the rigid body

    _biasAngularVelocity: number

    Temporary solver angular velocity used for contact separation

    _biasLinearVelocity: Vector

    Temporary solver velocity used for contact separation

    _centralForce: Vector

    Force applied at the rigid body center

    _centralImpulse: Vector

    Impulse applied at the rigid body center

    _movementTarget: Vector | null

    Pending one-step kinematic movement target

    _pointForces: PointForce[]

    Forces applied at world-space positions

    _pointImpulses: PointImpulse[]

    Impulses applied at world-space positions

    _prevAngularVelocity: number

    Angular velocity from the start of the current physics step

    _prevLinearVelocity: Vector

    Linear velocity from the start of the current physics step

    _torque: number

    Torque applied to the rigid body

    actor?: Actor
    angularDamping: number

    Angular damping used to slow down rotation over time

    angularVelocity: number

    Current angular velocity of the rigid body in radians per second

    disabled: boolean

    Whether rigid body simulation is disabled

    gravityScale: number

    Gravity multiplier. 0 ignores gravity, 1 uses normal world gravity.

    linearDamping: number

    Linear damping used to slow down movement over time

    linearVelocity: Vector

    Current linear velocity in world units per second

    lockRotation: boolean

    Whether dynamic rotation is locked. Locked bodies do not spin from torque or contacts.

    oneWay: boolean

    Whether contacts should only be resolved from one side

    oneWayNormal?: Vector

    Local-space normal that points toward the blocking side

    type: RigidBodyType

    Body type that defines how the rigid body participates in simulation

    componentName: string
    • get friction(): number

      Surface friction used by contact resolution. Higher values reduce sliding more strongly.

      Returns number

    • set friction(value: number): void

      Parameters

      • value: number

      Returns void

    • get inertia(): number

      Returns number

    • set inertia(value: number): void

      Moment of inertia used by dynamic bodies.

      Inertia is the rotational equivalent of mass: higher values make the body harder to spin. It is automatically computed from the collider shape, mass, and collider offset every physics step, so user code usually should only read this value.

      Parameters

      • value: number

      Returns void

    • get inverseInertia(): number

      Returns the inverse moment of inertia.

      This is the solver-friendly form of inertia. Static bodies, kinematic bodies, locked rotation, or non-positive inertia return 0.

      Returns number

    • get inverseMass(): number

      Returns the inverse mass.

      Bodies with zero or negative mass return 0.

      Returns number

    • get mass(): number

      Returns number

    • set mass(value: number): void

      Sets the mass used by dynamic bodies.

      Mass is an authored, kilogram-like scalar. Non-positive values make the body immovable by forces and impulses.

      Parameters

      • value: number

      Returns void

    • get restitution(): number

      Bounciness used by contact resolution. 0 does not bounce, 1 keeps full bounce speed.

      Returns number

    • set restitution(value: number): void

      Parameters

      • value: number

      Returns void

    • Adds an instantaneous angular impulse to a dynamic body for the next physics step.

      Angular impulse is an immediate rotational kick. Affects only active dynamic bodies with unlocked rotation.

      Parameters

      • impulse: number

      Returns void

    • Adds a continuous force to a dynamic body for the next physics step.

      Affects only active dynamic bodies. When position is provided, it is a world-space point where the force is applied; off-center forces can also rotate the body.

      Parameters

      Returns void

    • Adds an instantaneous impulse to a dynamic body for the next physics step.

      Affects only active dynamic bodies. An impulse is a one-step velocity kick. When position is provided, it is a world-space point where the impulse is applied; off-center impulses can also rotate the body.

      Parameters

      Returns void

    • Adds a continuous torque to a dynamic body for the next physics step.

      Torque is rotational force: it changes angular velocity over time. Affects only active dynamic bodies with unlocked rotation.

      Parameters

      • torque: number

      Returns void

    • Clears all accumulated force and impulse values.

      Returns void

    • Moves a kinematic body to a target position on the next physics step.

      The physics system computes a one-step velocity from the current position to this target so contacts can react to the kinematic movement.

      Parameters

      Returns void