How to Detect Gaze & Gesture on Entity

It's a common system interaction to look at an item in SwiftUI and tap to select it.

I'm confused how to do the same with ModelEntities.

How do I use gaze to select a ModelEntity for context based actions? e.g. look at the green sphere and tap to pull up a menu. Or look in a direction and clap to **** away virtual objects etc. etc.

If this is not possible is there a workaround?

Answered by Engineer in 791377022

You can target SwiftUI gestures to RealityKit entities, which need to have both a CollisionComponent and an InputTargetComponent in order to enable this behavior.

This is also explained in the following 2023 WWDC talk:

You can also explore the developer samples here:

You can target SwiftUI gestures to RealityKit entities, which need to have both a CollisionComponent and an InputTargetComponent in order to enable this behavior.

This is also explained in the following 2023 WWDC talk:

You can also explore the developer samples here:

How to Detect Gaze & Gesture on Entity
 
 
Q