- Home /
Creating a Matrix4x4 from an Object's Transform
Hello. I am trying to move and rotate objects based on the position and rotation of the camera. For instance, if the camera is rotated 45 degrees to the left around its forward vector, any objects that rotate along the x or y axis should do so around this new 45 degree angle.
I was hoping there was a way to make a new matrix by passing in an objects transform, and then rotate another object using that matrix.
Not sure the best way to do this with Unity.
Answer by FortisVenaliter · May 20, 2016 at 09:06 PM
You probably want the quaternion rather than the matrix. The matrix would have position and scaling included. But you can pull the rotation quaternion right from the transform and multiply it with any coordinates your need rotated.
Your answer
Follow this Question
Related Questions
How to Decompose a TRS Matrix? 3 Answers
Quaternion to Matrix Conversion Error - Camera Script 0 Answers
Change the roll of the rotation 0 Answers
Matrices to rotation 1 Answer
Quaternion To Matrix conversion failed because input Quaternion is invalid 1 Answer