One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

CollisionComponent

struct · iOS 13.0+ · SDK 27.1

struct CollisionComponent

A component that gives an entity the ability to collide with other entities that also have collision components. This component holds the entity's data related to participating in the scene's physics simulation. It is also used to calculate collision queries, raycasts, and convex shape casts. Entities can participate in the scene simulation in two different modes: as a *rigid body* or as a *trigger*. A rigid body fully participates in the collision simulation. It affects the velocity and direction of entities it collides. If configured with a rigid body ``RealityKit/PhysicsBodyComponent/mode`` of ``RealityKit/PhysicsBodyMode/dynamic``, it's own velocity and direction can be affected by other rigid body entities. A trigger entity doesn't have any impact on the rigid bodies in the scene, but can trigger code or Reality Composer behaviors when a rigid body entity overlaps it. Note the following when considering applying a non-uniform scale to an entity: - Non-uniform scaling is applicable only to box, convex mesh and triangle mesh collision shapes. - Non-uniform scaling is not supported for all other types of collision shapes. In this case the scale.x value is duplicated to the scale's y and z components as well to force scale uniformity based on the x component. - If the entity has a non-uniform scale assigned to its transform then that entity should not have any descendants assigned that contain rotations in their transforms. A good rule of thumb is to assign the non-uniform scale to the entity that has the collision shape, and avoid adding children below that entity. Turn an entity into a trigger by adding a ``RealityKit/CollisionComponent`` to it and setting its ``RealityKit/CollisionComponent/mode-swift.property`` to ``RealityKit/CollisionComponent/Mode-swift.enum/trigger``. Turn an entity into a _rigid body_ by adding a ``RealityKit/PhysicsBodyComponent`` to the entity in addition to a ``RealityKit/CollisionComponent``. The ``PhysicsBodyComponent`` defines the physical properties of the entity, such as its mass and collision shape. The `filter` property defines the entity's collision filter, which determines which other objects the entity collides with. For more information, see <doc://com.apple.documentation/documentation/realitykit/controlling_entity_collisions_in_realitykit>. - Note: If an entity has a ``RealityKit/PhysicsBodyComponent``, the collision component's mode is ignored. An entity can be a rigid body, or a trigger, but not both at the same time.

Members (13)

get · iOS 18.0+

collisionOptions

TypeScript
get collisionOptions(): CollisionComponent_CollisionOptions
Swift declaration
var collisionOptions: CollisionComponent.CollisionOptions { get set }
set · iOS 18.0+

collisionOptions

TypeScript
set collisionOptions(value: CollisionComponent_CollisionOptions)
Swift declaration
var collisionOptions: CollisionComponent.CollisionOptions { get set }
get · iOS 13.0+

mode

TypeScript
get mode(): CollisionComponent_Mode
Swift declaration
var mode: CollisionComponent.Mode

The collision mode.

set · iOS 13.0+

mode

TypeScript
set mode(value: CollisionComponent_Mode)
Swift declaration
var mode: CollisionComponent.Mode

The collision mode.

get · iOS 13.0+

filter

TypeScript
get filter(): CollisionFilter
Swift declaration
var filter: CollisionFilter

The collision filter used to segregate entities into different collision groups.

set · iOS 13.0+

filter

TypeScript
set filter(value: CollisionFilter)
Swift declaration
var filter: CollisionFilter

The collision filter used to segregate entities into different collision groups.

init · iOS 18.0+

init

TypeScript
static initShapesModeCollisionOptionsFilter(shapes: Array<ShapeResource>, mode: CollisionComponent_Mode, collisionOptions: CollisionComponent_CollisionOptions, filter?: CollisionFilter): CollisionComponent
Swift declaration
init(shapes: [ShapeResource], mode: CollisionComponent.Mode = .default, collisionOptions: CollisionComponent.CollisionOptions, filter: CollisionFilter = .default)
init · iOS 13.0+

init

TypeScript
static initShapesModeFilter(shapes: Array<ShapeResource>, mode?: CollisionComponent_Mode, filter?: CollisionFilter): CollisionComponent
Swift declaration
init(shapes: [ShapeResource], mode: CollisionComponent.Mode = .default, filter: CollisionFilter = .default)

Creates a collision component with the given collision shape, mode, and filter parameters. - Parameters: - shapes: The collection of shapes that collectively define the outer dimensions of the associated entity for the purposes of collision detection. - mode: The mode of the collision component. - filter: A filter that limits the other entities with which the entity can collide.

init · iOS 18.0+

init

TypeScript
static initShapesIsStaticFilter(shapes: Array<ShapeResource>, isStatic: boolean, filter?: CollisionFilter): CollisionComponent
Swift declaration
init(shapes: [ShapeResource], isStatic: Bool, filter: CollisionFilter = .default)

Creates a collision component.

get · iOS 13.0+

shapes

TypeScript
get shapes(): Array<ShapeResource>
Swift declaration
var shapes: [ShapeResource]

A collection of shape resources that collectively represent the outer dimensions of an entity for the purposes of collision detection.

set · iOS 13.0+

shapes

TypeScript
set shapes(value: Array<ShapeResource>)
Swift declaration
var shapes: [ShapeResource]

A collection of shape resources that collectively represent the outer dimensions of an entity for the purposes of collision detection.

get · iOS 18.0+

isStatic

TypeScript
get isStatic(): boolean
Swift declaration
var isStatic: Bool { get set }

A Boolean value that indicates whether the collider is static. When an object is static the physics engine recognizes that the object isn't moving, which typically improves performance.

set · iOS 18.0+

isStatic

TypeScript
set isStatic(value: boolean)
Swift declaration
var isStatic: Bool { get set }

A Boolean value that indicates whether the collider is static. When an object is static the physics engine recognizes that the object isn't moving, which typically improves performance.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →