Rotate gameObject by applying rotation matrix in unity3d
Is it possible to rotate a gameObject by applying Rotation matrix to it instead of passing each angle and rotating it.
I tried to use GL.MultMatrix() but there is no movement in gameobject
Code sinppet:
GL.PushMatrix();
GL.MultMatrix(m);
GL.PopMatrix();
The above snippet is in update() function. Docs says GL.MultMatrix() is similar to glMultMatrix in opengl library.Which we can use in openGl to Rotate right!!
If there is any method to achieve this please mention. Thanks
Unity provides some much higher level methods to provide you the fucntionality of matrix rotation. Its so high level its seen at the transform level. That is not to say you could not address it at the matrix level. Unity provides both eulerAngles wrapper and Quaternion wrapper functionality. tehy both offer rotation and are optimized for it in general. As a tip... If you want to rotate but not b ein a constant state of rotation - then choose a euler method If, on the other hand, you have a rotation that is in a constant state of rotation and can rotate across multiple axis - then use a quaternion method. Euler is generally cheaper (in terms of load) but prone to something known as gimble lock Quaternions are more expensive to some degree but you are left with a better and more reliable method of rotation - they use complex numbers to establish a quotient between two angles and use tuples to store the data as the data is usually large compared to a euler. Anyway ist a choice you can make by design, so... sorry this doesnt answer your glmatrix question but ask yourself if you relaly need to go lower. For example, you can deploy to webgl through Unity and still not have to write native OGL. Cheers bud, hope it helps in some way