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.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
borderRadius |
0 ≤ x ≤ 100 |
|
collision |
0 ≤ x ≤ 15, integer |
|
friction |
0 ≤ x ≤ 5 |
|
offset |
||
offset.x |
- |
|
offset.y |
- |
|
offset.z |
- |
|
restitution |
0 ≤ x ≤ 1 |
|
rotation |
||
rotation.x |
||
rotation.y |
||
rotation.z |
||
size.x |
0. |
|
size.y |
0. |
|
size.z |
0. |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
PhysicsCollider::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
Carry a crateE switches a crate between kinematic, led in front of the camera with setKinematicTarget, and dynamic, falling freely; its collider is kept.
Click the scene, then press E to pick the crate up, orbit the camera, and press E again to drop it.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(BoxColliderComponent); if (component) log(component.props);}