Skip to Content
🎉 @playcanvas/react 0.3.0! Now with React 19 support. Read more →
️💡

Run npm i sync-ammo and use <Application usePhysics/> to enable physics.

The Rigidbody component enables physics for an Entity, allowing it to interact with the global physics simulation. You can apply forces, torques, and other physics behaviours to an entity with a Rigidbody component and it will respond accordingly.

You can learn more about how physics work in PlayCanvas in the Physics docs.

Usage

import { Rigidbody } from '@playcanvas/react/components' <Entity> <Rigidbody type="dynamic" mass={12} /> <Render type="box" /> </Entity> }

Props

The following props are based on the RigidBody Component from PlayCanvas version 2.3.3. This documentation is automatically generated from the TypeScript types of the installed PlayCanvas package.

NameTypeDefault
typestring

Sets the rigid body type determines how the body is simulated.

"static"
angularDampingnumber

Sets the rate at which a body loses angular velocity over time. Gets the rate at which a body loses angular velocity over time.

angularFactor[number, number, number]

Sets the scaling factor for angular movement of the body in each axis. Only valid for rigid bodies of type BODYTYPE_DYNAMIC. Defaults to 1 in all axes (body can freely rotate). Gets the scaling factor for angular movement of the body in each axis.

angularVelocity[number, number, number]

Sets the rotational speed of the body around each world axis. Gets the rotational speed of the body around each world axis.

bodyany
frictionnumber

Sets the friction value used when contacts occur between two bodies. A higher value indicates more friction. Should be set in the range 0 to 1. Defaults to 0.5. Gets the friction value used when contacts occur between two bodies.

groupnumber

Sets the collision group this body belongs to. Combine the group and the mask to prevent bodies colliding with each other. Defaults to 1. Gets the collision group this body belongs to.

linearDampingnumber

Sets the rate at which a body loses linear velocity over time. Defaults to 0. Gets the rate at which a body loses linear velocity over time.

linearFactor[number, number, number]

Sets the scaling factor for linear movement of the body in each axis. Only valid for rigid bodies of type BODYTYPE_DYNAMIC. Defaults to 1 in all axes (body can freely move). Gets the scaling factor for linear movement of the body in each axis.

linearVelocity[number, number, number]

Sets the speed of the body in a given direction. Gets the speed of the body in a given direction.

masknumber

Sets the collision mask sets which groups this body collides with. It is a bit field of 16 bits, the first 8 bits are reserved for engine use. Defaults to 65535. Gets the collision mask sets which groups this body collides with.

massnumber

Sets the mass of the body. This is only relevant for BODYTYPE_DYNAMIC bodies, other types have infinite mass. Defaults to 1. Gets the mass of the body.

restitutionnumber

Sets the value that controls the amount of energy lost when two rigid bodies collide. The calculation multiplies the restitution values for both colliding bodies. A multiplied value of 0 means that all energy is lost in the collision while a value of 1 means that no energy is lost. Should be set in the range 0 to 1. Defaults to 0. Gets the value that controls the amount of energy lost when two rigid bodies collide.

rollingFrictionnumber

Sets the torsional friction orthogonal to the contact point. Defaults to 0. Gets the torsional friction orthogonal to the contact point.

systemComponentSystem

The ComponentSystem used to create this Component.

entityEntity

The Entity that this Component is attached to.

enabledboolean

Sets the enabled state of the component. Gets the enabled state of the component.

Last updated on