An invisible 3D shape that detects when objects enter or exit a given region of space.


class TriggerVolume : Entity


A trigger volume is an entity that can participate in collisions because it has a CollisionComponent. You use a trigger volume as a sensor that indicates when another collision-capable entity, like a ModelEntity, enters the region of space occupied by the trigger volume. You can use the generated CollisionEvents between the trigger volume and the other entity to trigger an action, like indicating to the user that a projectile hit its target.

Diagram showing the components present in the trigger volume entity.

The trigger volume itself is very simple. It lacks any physical appearance, and doesn’t participate in physics simulations. This makes it very efficient for tasks that require only collision detection.


Creating a Trigger Volume


Creates a trigger volume.

init(shape: ShapeResource, filter: CollisionFilter)

Creates a trigger volume with the given shape and collision filter.

init(shapes: [ShapeResource], filter: CollisionFilter)

Creates a trigger volume with the given composite shape and collision filter.

func clone(recursive: Bool) -> Self

Duplicates a trigger volume to create a new trigger volume.

Identifying a Trigger Volume

var id: ObjectIdentifier

The stable identity of the entity associated with self.

var id: UInt64

The stable identity of the trigger volume.

typealias TriggerVolume.ID

A type of unique identifier used for a trigger volume.

Detecting Collisions

var collision: CollisionComponent?

The collision component that gives the entity the ability to participate in collision simulations.

struct CollisionComponent

A component that gives an entity the ability to collide with other entities that also have collision components.

Loading a Stored Entity

Stored Entities

Manage entities stored as assets on disk.

Positioning Entities in Space

Finding the Nearest Anchor

Calculating the Collision Shape

Describing the Trigger Volume

See Also

Scene Elements

class AnchorEntity

An anchor that tethers virtual content to a real-world object in an AR session.

class ModelEntity

A representation of a physical object that RealityKit renders and optionally simulates.

class BodyTrackedEntity

An entity used to animate a virtual character in an AR scene by tracking a real person.