Skip to content

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.

The props the runtime declares for this component, with their defaults and accepted ranges.

Prop Default Range
angularDamping 0 ≤ x ≤ 100
gravityScale 0 ≤ x ≤ 1
linearDamping 0 ≤ x ≤ 100
mass 0 ≤ x ≤ 1000000

Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.

  • PhysicsRigidBody::sleep
  • PhysicsRigidBody::wake
  • PhysicsCollider::collision-enter
  • PhysicsCollider::collision-exit
  • PhysicsCollider::intersection-enter
  • PhysicsCollider::intersection-exit

Run it in the browser, read its scripts, and download it as an XR Creator project.

#pragma lifecycle(startup)
function startup() {
const component = self.parent.getComponent(PhysicsRigidBodyComponent);
if (component) log(component.props);
}