- Home /
Finding Position based on a local perspective
I need to find the relative location of an object based on a GameObject's local perspective. Best way i could think to describe it was a crude example pic :)
I need to be able to tell the circle (which could be anywhere in the world space) if the triangle is to the left or right of the square based on where the circle is. Again, the circle can be in any location at any time, so it needs to be somewhat dynamic.
I dont need any help with writing the scripts, just on how to get this info from the Unity engine. If this has a name or documentation I would be happy with just a link for an answer.
Thanks in advance to anyone who can point me in the right direction!
Answer by syclamoth · Dec 19, 2011 at 06:37 AM
Yes, it has a name in the Unity engine- you should read up on your documentation before asking questions as simple as this.
Use
transform.InverseTransformPoint(otherPosition);
to get the otherPosition relative to the transform.
ouch, no need for the hostility :/ I just didnt know what it was called and hadnt run across it yet. I do appreciate your answer though. Im headed in the right direction again. Thanks :)