LoginSignup
1
3

More than 5 years have passed since last update.

Unity | Rotation MatrixをUnity5.6で作成する

Last updated at Posted at 2017-10-24

World, View and Projection Transformation Matrices

Since Matrix4x4.Rotate does not exist in Unity5.6, you might need to make a rotation matrix from Matrix4x4. I found this article quite helpful.
(Unity5.6にはMatrix4x4.RotateがないのでMatrix4x4から自作する必要があるだろう。
この記事World, View and Projection Transformation Matricesが非常に参考になった。)

        Matrix4x4 rotmat = Matrix4x4.identity;

        rotmat.m00 = Mathf.Cos((yRotationDegree * Mathf.PI) / 180);
        rotmat.m02 = Mathf.Sin((yRotationDegree * Mathf.PI) / 180 * -1.0f);
        rotmat.m20 = Mathf.Sin((yRotationDegree * Mathf.PI) / 180);
        rotmat.m22 = Mathf.Cos((yRotationDegree * Mathf.PI) / 180);

You could multiply other matrices and rotmat.
(rotmatと他のMatrixをMultiplyすると取得したい結果が得られるだろう。)

Ref

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3