Hi! With the following code I am able to receive the location of taps in my RealityView.
How do I find out which of my entities was tapped (in order to execute an animation or movement)? I was not able to find anything close to ARView's entity(at:) unfortunately. Am I missing something, or is this not possible in the current beta of visionOS?
struct ImmersiveView: View {
var tap: some Gesture {
SpatialTapGesture()
.onEnded { event in
print("Tapped at \(event.location)")
}
}
var body: some View {
RealityView { content in
let anchor = AnchorEntity(.plane(.horizontal, classification: .table, minimumBounds: [0.3, 0.3]))
// adding some entities here...
content.add(anchor)
}
.gesture(tap.targetedToAnyEntity())
}
}