Object coordinates relative to camera

Hi !

I have a litte problem. I have a gameObject that is following my camera. When I print my abject's coordinates I observe they're not relative to my camera but to my world. How can I change that ?

Thanks !


relativePosition = cameraTransform.InverseTransformDirection(transform.position - cameraTransform.position);

If you make the game object a child of the camera in the hierarchy and use transform.localPosition, you should be able to get it.