- Home /
Math behind transform.TransformDirection?
I know TransformDirection can convert local to world coordinates. Can can tell me how the math behind the process works?
Answer by EvilTak · Dec 09, 2014 at 11:19 AM
The transform of a gameobject has a matrix storing information like position, rotation and scale. TransformDirection multiplies the input vector with the transform's matrix and returns the result. InverseTransformDirection multiplies the input vector with the transpose of the transform's matrix. In 3d it is a 4 by 4 matrix, in 2d 2 by 2 matrices are used.
thank you . may be i should google a method by c or c++ about the process. also to find the same process with mono game project, because it have open source code.
This is wrong. What you are describing is TransformPoint
, not TransformDirection
.
Answer by starikcetin · Jul 30, 2021 at 10:20 AM
You have to decompose the rotation component of the matrix.
There is a Matrix4x4.rotation property. It returns a Quaternion. Simply rotate your direction vector with that Quaternion.
Your answer

Follow this Question
Related Questions
how to move an object (noob) 2 Answers
Problem Javascript to C# 3 Answers
How do I modify the current transform? 2 Answers
Translate code from C# to Javascript 1 Answer
AddForce on diagonals C# 1 Answer