unknown_jy
unknown_jy

Reputation: 767

How do you display the current device position in ARKit?

I would like to display the current device position at every frame. I am very new to iOS app development so would appreciate a thorough instruction. I would like to know how I can run some function every time there is an update to the frame.

func session(_ session: ARSession, didUpdateFrame frame: ARFrame) {
    statusMessage.text = "Frame Updated"
}

This does not work because the ARSession does not go into 'didUpdateFrame' state.

Upvotes: 1

Views: 661

Answers (1)

nagam11
nagam11

Reputation: 133

Maybe you have forgotten to set the delegate. Adopt the ARSessionDelegate in your ViewController. Then, in viewWillAppear set the delegate to yourself

 sceneView.session.delegate = self

The method updateFrame should now be executed.

func session(_ session: ARSession, didUpdate frame: ARFrame) {
    print("Frame Updated")
}

On the other hand, you could also use the SCNSceneRendererDelegate and the method renderer(_:updateAtTime:)to setup your view before animations/actions etc.

Upvotes: 1

Related Questions