- Home /
Problem is not reproducible or outdated
How to use Matrix4x4?
So what is the nitty gritty of using Matrix4x4? I need to assign it in Graphics.DrawMeshInstanced but I am unfamiliar with how we assign these. I have all the positions and rotations ready to go.
Answer by TylerMorton · Dec 10, 2016 at 05:49 PM
On the Matrix4x4 page in the Unity Manual you can use the function Matrix4x4.TRS(), which constructs a Matrix applying a translation, rotation and scaling vector value. If you have all of these values, it should be trivial :)
Quaternion rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z); Matrix4x4 m = Matrix4x4.TRS(translation, rotation, scale);
Here's a link to the Unity scripting API for Matrix4x4.TRS()
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Maintaining direction while jumping / rotating 3 Answers
transform.localscale 1 Answer
how do i slowly translate a object to a other objects position 2 Answers