0

How do I include an entity in a collision group?

When I use func raycast(...) in RealityKit, the parameter mask defines: "A collision mask that you can use to prevent collisions with certain objects."

mask is CollisionGroup, how do I include my entity in the CollisionGroup? I want to use it prevent collisions with certain objects.

raycast(origin: SIMD3<Float>, direction: SIMD3<Float>, length: Float = 100, query: CollisionCastQueryType = .all, mask: CollisionGroup = .all, relativeTo referenceEntity: Entity? = nil) -> [CollisionCastHit]

Eric Wang
  • 154
  • 11
zhou junhua
  • 462
  • 1
  • 4
  • 12

1 Answers1

1

When you declare the entity's collision component, you have the option of setting the collision group.

Any entity that conforms to HasCollision has a collision variable that allows you to manipulate the CollisionComponent. It is through the CollisionComponent that you can manipulate the CollisionFilter and set the group an entity belongs to and the mask of entities it can collide with.

Eric Wang
  • 154
  • 11