Physics Rigid Body
Updated
Makes the entity a physics body: dynamic, fixed or kinematic.
- Type
comp-physics-rigid-body- Script class
PhysicsRigidBodyComponent- Per entity
- One
- Version
- 2.0.0
Read about it in Forces and impulses: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
angular |
0 ≤ x ≤ 100 |
|
gravityScale |
0 ≤ x ≤ 1 |
|
linearDamping |
0 ≤ x ≤ 100 |
|
mass |
0 ≤ x ≤ 1000000 |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
PhysicsRigidBody::sleepPhysicsRigidBody::wakePhysicsCollider::collision-enterPhysicsCollider::collision-exitPhysicsCollider::intersection-enterPhysicsCollider::intersection-exit
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
Respawn objects that fall off the worldA ball rolls down a ramp and off its end; once it is 10 m down, teleport puts its body back at its starting place, and it rolls again.
Watch the ball roll off the ramp, fall and come back to the top. Drag to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(PhysicsRigidBodyComponent); if (component) log(component.props);}