When I set the mode of a CollisionComponent in RealityKit to .trigger
it still collides with other objects. To my knowledge triggers should pass through other colliders. This is how I set up the triggers:
func addCube() {
let entity = ModelEntity(mesh: .generateBox(size: 0.1,
cornerRadius: 0.0),
materials: [SimpleMaterial(color: .red,
isMetallic: false)])
entity.collision = CollisionComponent(shapes: [ShapeResource.generateBox(width: 0.1,
height: 0.1,
depth: 0.1)],
mode: .trigger)
entity.physicsBody = PhysicsBodyComponent()
entity.setPosition([0.0, 0.2, 0.0], relativeTo: nil)
root.addChild(entity)
}
I can only set the CollisionComponent's filter correctly to ignore the same kind of entity, then they pass through each other, but then the subscription events of the colliders to not trigger anymore. Did someone manage to use triggers correctly in RealityKit?
In RealityKit, the
trigger
case makes a collision object with such a mode more performant. When an object of this type collides with other object, your app just records that a contact event was occurred. However, the app discards details like penetration depths, contact points and normal vectors, unlikeCollisionComponent.Mode.default
mode.