So I am tracking 2 objects in my scene, and spawning a tiny arrow on each of the objects (this part is working as intended).
Inside my scene I have added Collision Components and Physics Body Components to each of the arrows.
I want to detect when when a collision occurs between the 2 arrow entities.. I have made the collision boxes big enough so they should definitely be overlapping, however I am not able to detect when the Collision occurs.
This is the code that I use for the scene -
import SwiftUI
import RealityKit
import RealityKitContent
struct DualObjectTrackingTest: View {
@State private var subscription: EventSubscription?
var body: some View {
RealityView { content in
if let immersiveContentEntity = try? await Entity(named: "SceneFind.usda", in: realityKitContentBundle) {
content.add(immersiveContentEntity)
print("Collision check started")
}
} update: { content in
if let arrow = content.entities.first?.findEntity(named: "WhiteArrow") as? ModelEntity {
let subscription = content.subscribe(to: CollisionEvents.Began.self, on: arrow) { collisionEvent in
print("Collision has occured")
}
}
}
}
}
All I see in my console logs is "Collision check started" and then whenever I move the 2 objects really close to each other so as to overlap the collision boxes, I don't see any updates in the logs.
Can anyone give me some further guidance/resources on this?
Thanks again!