Skip to content

Box Collider

Updated

Box-shaped collision, fitted to the mesh by default.

Type
comp-box-collider
Script class
BoxColliderComponent
Per entity
Several
Version
2.0.0

Read about it in Collisions and triggers: 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
borderRadius 0 ≤ x ≤ 100
collisionLayer 0 ≤ x ≤ 15, integer
friction 0 ≤ x ≤ 5
offset
offset.x -10000 ≤ x ≤ 10000
offset.y -10000 ≤ x ≤ 10000
offset.z -10000 ≤ x ≤ 10000
restitution 0 ≤ x ≤ 1
rotation
rotation.x
rotation.y
rotation.z
size.x 0.001 ≤ x ≤ 10000
size.y 0.001 ≤ x ≤ 10000
size.z 0.001 ≤ x ≤ 10000

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

  • 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(BoxColliderComponent);
if (component) log(component.props);
}