kkrac
1
With the gameobject’s forward vector pointing to global positive x…
- transform.TransformDirection(Vector3.forward) outputs (1.0, 0.0, 0.0) … OK, understood.
- transform.TransformDirection(transform.forward) outputs (0.0, 0.0, -1.0) … Why?
Can someone explain why #2?
This line of code makes no sense. “TransformDirection” takes a local space direction vector as input. transform.forward is a worldspace direction.
Basically Those two lines are identical:
Vector3 fwd = transform.forward;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
Your code does interprets a worldspace direction as localspace direction and transforms it again. The result will be nonsense.
So this line:
transform.TransformDirection(transform.forward);
would be the same as doing
transform.TransformDirection(transform.TransformDirection(Vector3.forward));