Collisions are not detected if the entity is a child of a hand AnchorEntity

I have a created an AnchorEntity for my index finger tip and then created a model entity (A sphere) as a child of it. This model entity has a collision component and a physics body component. I tried using dynamic and kinematic modes for the physics body component.

I have created a plane from a cube that has collision component and a static physics body.

I have subscribed to the CollisionEvents.Began on this plane. I have also stored it in a EventSubscription state variable.

@State private var collisionSubscription: EventSubscription?

The I subscribed as follows

collisionSubscription = content.subscribe(to: CollisionEvents.Began.self,
 on: self.boxTopCollision, { collisionEvent in
    print("something collided with the box top")

 })

The collision event fires when I directly put the sphere above the plane and let gravity do the collision, but when the the sphere is the child of the anchor entity, the collision events don't happen.

I tried adding collision and physics body component directly to the anchor entity and that doesn't work too.

I created another sphere with a physics body and a collision component and input target component and manipulate it with a drag gesture. When the manipulation is happening and collide the plane and the sphere the events don't happen when my sphere is touching the plane, but when the gesture end and the sphere is in contact with the plane, the event gets fired. I am confused as to why this is happening.

All I want to do is have a collider on my finger tip and want to detect the collision with this plane. How can I make this work?

Is there some unstated rule somewhere as where a physics body is manipulated manually it cannot trigger collision events?

For more context. I am using SpatialTrackingSession with the tracking configuration of .hand. I am successfully able to track the finger tip.

You probably need to set their physics simulation to .none (https://developer.apple.com/documentation/realitykit/anchoringcomponent/physicssimulation-swift.enum/none). The default is .isolated where AnchorEntities run in their own Physics Simulation scope.

I tried setting the physics simulation to both .isolated and .none, both don't work. I tried setting it on the fingertip anchor entities, also on the boxTopColliision anchor. To be clear, I did it like

boxTopCollision.anchor?.anchoring.physicsSimulation = .none

Is this the right place to do it.

I also tried the same with the finger tip entities

handTrackingManager.rightIndexFingerTip.anchor?.anchoring.physicsSimulation = .none

I tried it together and one at a time still no avail.

Hi @doomdave

As @arthurfromberlin mentioned, the key to enabling collisions for an AnchorEntity anchored to a person's hands is to set the physicsSimulation property to .none, as well as to start a SpatialTrackingSession. Since it appears that you have already taken both of these steps, it's difficult for me to know what else might be going wrong without seeing more code.

Feel free to share a longer snippet demonstrating this issue if you're comfortable doing so; otherwise, here's an example demonstrating how to detect collisions between the child of a hand AnchorEntity and a cube that you can compare with or build off of.

RealityView { content in
    // Start a spatial tracking session.
    let configuration = SpatialTrackingSession.Configuration(tracking: [.hand])
    let session = SpatialTrackingSession()
    await session.run(configuration)
    
    // Create a cube with collision.
    let collidableCube = ModelEntity(mesh: .generateBox(width: 0.25, height: 0.05, depth: 0.25), materials: [SimpleMaterial(color: .green.withAlphaComponent(0.75), isMetallic: false)])
    collidableCube.position = [0, 1, -0.5]
    collidableCube.generateCollisionShapes(recursive: false)
    content.add(collidableCube)
    
    // Create an anchor entity tracking the right index finger tip.
    let rightIndexTipAnchor = AnchorEntity(.hand(.right, location: .indexFingerTip))
    rightIndexTipAnchor.anchoring.physicsSimulation = .none
    content.add(rightIndexTipAnchor)
    // Create a child entity with collision.
    let rightIndexTipCollisionEntity = ModelEntity(mesh: .generateSphere(radius: 0.01), materials: [SimpleMaterial()])
    rightIndexTipCollisionEntity.generateCollisionShapes(recursive: false)
    rightIndexTipAnchor.addChild(rightIndexTipCollisionEntity)
    
    // Subscribe to collision events.
    _ = content.subscribe(to: CollisionEvents.Began.self, on: rightIndexTipCollisionEntity) { collisionEvent in
        print("Collision began.")
    }
}

Be sure to add an entry for NSHandsTrackingUsageDescription to your app’s information property list to provide a usage description that explains how your app uses the hand tracking information.

Collisions are not detected if the entity is a child of a hand AnchorEntity
 
 
Q