sorry for my bad english! I will try to explain the situation. Im just playing with this function because i want to understand how it works. The concept is really clear but debugging the forward of the object that i am debugging i get really weird output. For example im using InverTranformDirection(Vector3.Forward) to see what vector i get from the object child of another object. They are both perfectly aligned with their own axies. If i try rotate the parent of the object in order to have the forward pointing at (0,0,1) the child object that i am debugging has the same z axis value like it should have because they are alligned but if i rotate the parent to get the forward rotated on the (1,0,0) space cordinates, i get the cordinates inverted (-1,0,0). I mean why? Parent and child are pointing they own forward in the same exactly direction. Could you help me understand? Thanks!
InverseTranformDirection(Vector3.Forward)
wouldn't care about the parent at all. It is simply converting the world space global Z axis direction (= (0, 0, 1)
) into local space of the according object.
I'd say it does exactly what you would expect.
Rotating your object to its own forward vector points towards (1,0,0)
(=Vector3.right
= world X axis) basically means the world space forward vector (0, 0, 1)
(=Vector3.forward
) is now pointing left away from your object.
Which is what (-1, 0, 0)
would mean in its local space.
Vector3.forward (= -transform.right)
(world Z axis) (local negative X axis)
^
|
|
rotated Object ----> Vector3.right (= transform.forward)
(world X axis) (local Z axis)