I'm new to swift, and I'm trying to get the location of the camera in the ARKit example, but it's giving me nil
.
I used the solution for this question and set the delegate to self
, but it's still not giving me the camera transform.
What am I doing wrong?
class ViewController: UIViewController, ARSCNViewDelegate {
@IBOutlet var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
sceneView.delegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let configuration = ARWorldTrackingSessionConfiguration()
sceneView.session.run(configuration)
}
func session(_ session: ARSession, didUpdate frame: ARFrame) {
print("Hello") // DOES NOT RUN HERE
let currentTransform = frame.camera.transform
}
}