CollisionComponent
A component that gives an entity the ability to collide with other entities that also have collision components.
Declaration
struct CollisionComponentOverview
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 mode of 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 CollisionComponent to it and setting its mode to CollisionComponent.Mode.trigger.
Turn an entity into a rigid body by adding a PhysicsBodyComponent to the entity in addition to a 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 Controlling Entity Collisions in RealityKit.