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 !
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 !
http://unity3d.com/support/documentation/ScriptReference/Transform.InverseTransformDirection.html
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.