I am playing around in Realitykit and would like an Entity to always look at camera. I've seen similar questions on stackoverflow and developer forums and followed their suggestion to use look(at) method. I am aware that reality composer can achieve the same effect using behavior but I would later have to use the same technique to anchor an Arrow to the camera using AnchorEntity and have it look at another entity in the scene for user navigation.
I am using look(at) method to orient the entity to the camera right now by calling it in ARKit session Didupdate method, however, it is broken:
entity.look(at: arView.cameraTransform.translation, from: entity.position, upVector: [0,0,0], relativeTo: nil)
This will move my entity to a new position in the scene and since it is called at ARKit session Didupdate it will keep moving further and further away every frame. I thought it is not supposed to move since I've set the "from:" to object's current position so it always move to where it was and hence static. My entity is an AnchorEntity that act as a root entity for the model loaded from reality composer.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
I am trying to use ARWorldmap to save and load the data to relocalize the scene. The example I used was from apple's documentation: https://developer.apple.com/documentation/arkit/world_tracking/saving_and_loading_world_data
However, this example uses scenekit to render, and I want to use realitykit.
In the example, they use: Scenekit renderer didAdd to render everytime a new anchor has been added.
What I did was to swap out the scenekit in the example and replace the method above with ARsession's didAdd Anchors and create a new anchorentity from the anchor added.
The app runs with no problem until I tried to load the saved world data. The anchor restored with no problem at all with the correct coordinate. ARsession's didAdd Anchors function was called and it recreates my AnchorEntity at the anchor location.
However, my anchorentity created in the didAdd anchors method is at the wrong location as they randomly drifted from where they were supposed to be.
Anyone has any clue on how to solve this?