2

I am creating a Plane with a VideoMaterial and placing it over a recognized image. The anchor for the plane is created like this:

let anchor = AnchorEntity(world: imageAnchor.transform)

And that works fine for the initial location. But I want it to stay in place as I move the phone around, and it doesn't. It doesn't quite follow the phone, either, but it moves in the same general direction.

I think the fix for this is to keep updating the anchor's transform in didUpdate, but to what? I only have the current transform of the imageAnchor and no way to convert it to world coordinates. I tried using it unconverted and the plane ended in an entirely wrong place.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
janineanne
  • 585
  • 7
  • 17

1 Answers1

1

Tracking native and ARKit anchors in RealityKit


Native RealityKit's case image(group: String, name: String) automatically tracks its target (image).

AnchorEntity(.image(group: "ARGroup", name: "myImage"))

If you prefer to track ARKit's ARImageAnchor, then use session(_:didUpdate:) delegate method.

AnchorEntity(anchor: arImageAnchor) 
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • 1
    Andy, thank you for your help! Your posts have been super helpful to me as I've been learning ARKit. Way better than Apple's documentation. I didn't do exactly what you suggested here, but it led me to a partial solution. This question was actually a simplified version of what I'm doing. I've posted a new question with more info at https://stackoverflow.com/questions/75943774/keeping-entity-anchored-in-place-as-phone-moves Thank you in advance if you are able to take a look at it! – janineanne Apr 05 '23 at 20:42