ARKit – Position of the ARCamera

You can use the ARCamera.transform property to get the current transform of your camera. The following code is from Introducing ARKit at WWDC 2017 which you probably want to watch as an introduction. We are using the transform to place a node 10 cm in front of the camera.

In Swift:

var translation = matrix_identity_float4x4
translation.columns.3.z = -0.1 // Translate 10 cm in front of the camera
node.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)

In Objective-C

matrix_float4x4 translation = matrix_identity_float4x4;
translation.columns[3][2] = -0.1; // Translate 10 cm in front of the camera
node.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)