Hi everyone,
We have a cube game object and the script is attached to this cube.
You draw a ray using:
Debug.DrawRay(transform.position, Vector3.Forward);
This code draws a ray that faces the world z direction. If you rotate the cube the ray does not rotate with it. The ray still faces the world z direction.
You then draw a ray using:
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.foward));
This code draws a ray that faces the cube’s z direction. If you rotate the cube, the ray rotates with it.
It looks like Transform.TransformDirection() transforms a world direction into a local direction.
However when you look at Unity scripting API definition of Transform.TransformDirection, it says:
Transforms “direction” from local space to world space.
It sounds like the API definition says the oppositite of what the code does.
Can anybody explain this ?
Thank you.

