Angular drag is a force that resists the rotation of the rigid-body. It is applied to the center-of-mass of the rigid-body.
When true the mass will be automatically calculated by the attached colliders
The center of mass is the point around which the mass of the rigid-body is evenly distributed. It is used to compute the torque applied to the rigid-body when forces are applied to it.
Constraints are used to lock the position or rotation of an object in a specific axis.
Detect collisions is a flag that can be set to false to disable collision detection for a specific rigid-body.
Rigidbodies with higher dominance will be immune to forces originating from contacts with rigidbodies of lower dominance.
Drag is a force that resists the motion of the rigid-body. It is applied to the center-of-mass of the rigid-body.
Reference to the GameObject this component is attached to This is a three.js Object3D with additional GameObject functionality
Unique identifier for this component instance, used for finding and tracking components
IsKinematic is a flag that can be set to true to make a rigid-body kinematic. Kinematic rigid-bodies are not affected by forces and collisions. They are meant to be animated by the user.
The sleeping threshold is the minimum velocity below which a dynamic rigid-body will be put to sleep by the physics engine.
Optional
sourceIdentifier for the source asset that created this component. For example, URL to the glTF file this component was loaded from
Use gravity is a flag that can be set to false to disable gravity for a specific rigid-body.
Checks if this component is currently active (enabled and part of an active GameObject hierarchy) Components that are inactive won't receive lifecycle method calls
True if the component is enabled and all parent GameObjects are active
Checks if this component has been destroyed
True if the component or its GameObject has been destroyed
Controls whether this component is enabled Disabled components don't receive lifecycle callbacks
Gets the forward direction vector (0,0,-1) of this component's GameObject in world space
Gravity is such a common force that it is implemented as a special case (even if it could easily be implemented by the user using force application). Note however that a change of gravity won't automatically wake-up the sleeping bodies so keep in mind that you may want to wake them up manually before a gravity change.
It is possible to change the way gravity affects a specific rigid-body by setting the rigid-body's gravity scale to a value other than 1.0. The magnitude of the gravity applied to this body will be multiplied by this scaling factor. Therefore, a gravity scale set to 0.0 will disable gravity for the rigid-body whereas a gravity scale set to 2.0 will make it twice as strong. A negative value will flip the direction of the gravity for this rigid-body.
The layer value of the GameObject this component is attached to Used for visibility and physics filtering
By default the mass will be automatically calculated (see autoMass
) by the physics engine using the collider sizes
To set the mass manually you can either set the mass
value or set autoMass
to false
The name of the GameObject this component is attached to Used for debugging and finding objects
Gets the right direction vector (1,0,0) of this component's GameObject in world space
Shorthand accessor for the current scene from the context
The scene this component belongs to
Returns the rigidbody velocity smoothed over ~ 10 frames
Indicates whether the GameObject is marked as static Static objects typically don't move and can be optimized by the engine
The tag of the GameObject this component is attached to Used for categorizing objects and efficient lookup
Gets the up direction vector (0,1,0) of this component's GameObject in world space
Gets the rotation of this component's GameObject in world space as a quaternion
Sets the rotation of this component's GameObject in world space using a quaternion
The world rotation quaternion to set
Forces affect the rigid-body's acceleration whereas impulses affect the rigid-body's velocity the acceleration change is equal to the force divided by the mass:
Forces affect the rigid-body's acceleration whereas impulses affect the rigid-body's velocity the velocity change is equal to the impulse divided by the mass
Called once when the component becomes active for the first time. This is the first lifecycle callback to be invoked
Destroys this component and removes it from its GameObject After destruction, the component will no longer receive lifecycle callbacks
Dispatches an event to all registered listeners
The event object to dispatch
Always returns false (standard implementation of EventTarget)
Optional
earlyCalled at the beginning of each frame before regular updates. Use for logic that needs to run before standard update callbacks.
The velocity of a dynamic rigid-body controls how fast it is moving in time. The velocity is applied at the center-of-mass of the rigid-body. This method returns the current angular velocity of the rigid-body.
The velocity of a dynamic rigid-body controls how fast it is moving in time. The velocity is applied at the center-of-mass of the rigid-body. This method returns the current linear velocity of the rigid-body.
Optional
lateCalled after all update functions have been called. Use for calculations that depend on other components being updated first.
Optional
onCalled after the scene has been rendered. Use for post-processing or UI updates that should happen after rendering
Optional
onCalled immediately before the scene is rendered.
Current XRFrame if in an XR session, null otherwise
Optional
onCalled before an XR session is requested Use to modify session initialization parameters
The XR session mode being requested
The session initialization parameters that can be modified
Optional
onCalled when this component's collider begins colliding with another collider.
Information about the collision that occurred
Optional
onCalled when this component's collider stops colliding with another collider.
Information about the collision that ended
Optional
onCalled each frame while this component's collider is colliding with another collider
Information about the ongoing collision
Called when the component is destroyed. Use for cleanup operations like removing event listeners
Called every time the component becomes disabled or inactive in the hierarchy. Invoked when the component or any parent GameObject becomes invisible
Optional
onCalled when this component joins an XR session or becomes active in a running session
Event data for the XR session
Optional
onCalled when this component exits an XR session or becomes inactive during a session
Event data for the XR session
Optional
onCalled when the context's pause state changes.
Whether the context is currently paused
The previous pause state
Optional
onCalled when a pointer completes a click interaction with this component's GameObject
Data about the pointer event
Optional
onCalled when a pointer button is pressed while over this component's GameObject
Data about the pointer event
Optional
onCalled when a pointer enters this component's GameObject
Data about the pointer event
Optional
onCalled when a pointer exits this component's GameObject
Data about the pointer event
Optional
onCalled when a pointer moves while over this component's GameObject
Data about the pointer event
Optional
onCalled when a pointer button is released while over this component's GameObject
Data about the pointer event
Optional
onCalled when this component's trigger collider is entered by another collider
The collider that entered this trigger
Optional
onCalled when another collider exits this component's trigger collider
The collider that exited this trigger
Optional
onCalled each frame while another collider is inside this component's trigger collider
The collider that is inside this trigger
Optional
onCalled each frame while this component is active in an XR session
Event data for the current XR frame
Called when a field decorated with @validate() is modified.
Optional
onXRControllerCalled when an XR controller is connected or when this component becomes active in a session with existing controllers
Event data for the controller that was added
Optional
onXRControllerCalled when an XR controller is disconnected or when this component becomes inactive during a session with controllers
Event data for the controller that was removed
Optional
resolveCalled when this component needs to remap guids after an instantiate operation.
Mapping from old guids to newly generated guids
Optional
wakeup: booleanOptional
wakeup: booleanOptional
y: numberOptional
z: numberSet the angular velocity of a rigidbody (equivalent to calling setAngularVelocity
)
Set the angular velocity of a rigidbody (equivalent to calling setAngularVelocity
)
Optional
y: numberOptional
z: numberSets the position of this component's GameObject in world space using individual coordinates
X-coordinate in world space
Y-coordinate in world space
Z-coordinate in world space
Sets the rotation of this component's GameObject in world space using quaternion components
X component of the quaternion
Y component of the quaternion
Z component of the quaternion
W component of the quaternion
Sets the rotation of this component's GameObject in world space using individual Euler angles
X-axis rotation
Y-axis rotation
Z-axis rotation
Whether the values are in degrees (true) or radians (false)
Optional
startCalled once at the beginning of the first frame after the component is enabled. Use for initialization that requires other components to be awake.
Starts a coroutine that can yield to wait for events. Coroutines allow for time-based sequencing of operations without blocking. Coroutines are based on generator functions, a JavaScript language feature.
Generator function to start
Event to register the coroutine for (default: FrameEvent.Update)
The generator function that can be used to stop the coroutine
Stops a coroutine that was previously started with startCoroutine
The routine to be stopped
The frame event the routine was registered with
Optional
supportsXRDetermines if this component supports a specific XR mode
The XR session mode to check support for
True if the component supports the specified mode
Teleport the rigidbody to a new position in the world.
Will reset forces before setting the object world position
The new position to teleport the object to (world space)
When true the object will be teleported in local space, otherwise in world space
Optional
updateCalled once per frame during the main update loop. The primary location for frame-based game logic.
Call to force an update of the rigidbody properties in the physics engine
When a dynamic rigid-body doesn't move (or moves very slowly) during a few seconds, it will be marked as sleeping by the physics pipeline. Rigid-bodies marked as sleeping are no longer simulated by the physics engine until they are woken up. That way the physics engine doesn't waste any computational resources simulating objects that don't actually move. They are woken up automatically whenever another non-sleeping rigid-body starts interacting with them (either with a joint, or with one of its attached colliders generating contacts).
A Rigidbody is used together with a Collider to create physical interactions between objects in the scene.