Apologies for the multiple comments, I have now been able to fix the physics simulation issue. I'm now adding collision boxes and physics body components to the 2 entities that I am spawning on my 2 object anchors, and trying to detect a collision between the two when I place the 2 objects on top of each other. Does not seem to be working at the moment. Any advice on what I can do for this?
This is the code below that I'm using
struct DualObjectTrackingTest: View {
@State private var subs: [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")
if let Anchor1 = immersiveContentEntity.findEntity(named: "Object1"),
var transform1 = Anchor1.components[AnchoringComponent.self],
let Anchor2 = immersiveContentEntity.findEntity(named: "Object2"),
var transform2 = Anchor2.components[AnchoringComponent.self] {
transform1.physicsSimulation = .none
transform2.physicsSimulation = .none
}
}
} update: { content in
let event = content.subscribe(to: CollisionEvents.Began.self) { collisionEvent in
print("Collision HAS OCCURED!")
}
DispatchQueue.main.async {
subs.append(event)
}
}
}
}
I don't see any console logs indicating that the collision has occurred, even though the entities and their components (collision boxes) should technically be in the same coordinate and physical space..
Topic:
Spatial Computing
SubTopic:
General
Tags: