Reputation: 117
What is the difference between arView.session.add(anchor)
and arView.scene.addAnchor(anchor)
in RealityKit?
Upvotes: 3
Views: 542
Reputation: 1253
The anchor
in each of those examples are two different object types, the first is an ARAnchor, the second is an AnchorEntity.
If you create an AnchorEntity like this: AnchorEntity(plane: .horizontal), then it will attach to the first horizontal ARAnchor which is automatically created with ARKit's plane detection. However if you instead create an AnchorEntity in this way: AnchorEntity(world: [0, 0, -1]), then it will position it at that [0, 0, -1] in world space, not using any ARAnchors.
You might want to manually add an ARAnchor to the session if you want something to be positioned at the same place across two devices using collaborative sessions, but at an arbitrary location, such as [0, 0, -1] on one of the device's world space.
Upvotes: 3