I have a moveable main camera, and then a child object of that camera that I want to move on its xy plane relative to the camera in a way it stays centered (from the camera’s pov) on a moving object in front of it.
So this is the first thing my undercaffeinated brain coughed up :
( this is in Update of the script attached to the tracking object )
myTransform.localPosition = camTransform.InverseTransformPoint(Camera.main.WorldToViewportPoint(Camera.main.ViewportToWorldPoint(headTransform.position)));
And it doesn’t work at all, it just sticks the tracking object to the moving object in world space. Before I drive myself crazy with this, does anyone know the proper way to do it ?