Question by
Serge144 · Oct 18, 2021 at 11:51 AM ·
transformcoordinatescoordinate-systemtransformdirectioninversetransformpoint
Change Coordinate System of a direction vector (Vector3)
Let's say I have a Vector3 (1,0,0) called A which is basically the World's Vector3.right vector. Now imagine that I also have a GameObject that is in position (0,0,0) and its forward vector is facing the negative X axis, so the direction will be (-1,0,0).
What I want is to obtain the vector that results from taking the vector A and placing it into the coordinate system of this GameObject (considering its forward and up axis). So the resulting vector in this case would be (0,0,1) which is now the world's forward vector and this GameObject's right vector.
I have tried looking into InverseTransformDirection but with no success... Thank you in advance.
Comment
var dir = targetGo.transform.TransformDirection( Vector3.right );