I want to know how I can calculate the distance between an AR-object and the camera filming it, in order to make the object turn to the camera when being within a certain radius of the object.
Would really appreciate some concrete code examples of how to do this, given that you already have a marker and working virtual character placed on it, and already know how to turn the object in the cameras direction.
Thanks!
Would Vector3.Distance() help? It returns the distance between the two positions. Something like `Vector3 Dist = Vector3.Distance(Camera.main.transform.position,transform.position)
if(Dist <= TurnDist){
//do stuff
}`
just put this in the update function on your object that wants to turn.
Hope that helps!