[Unity Transform] rotation transformation

introduce

I found that I don't know much about the rotate in the Transform component of the GameObject, so I will sort it out here for notes.

Inspector Rotation

insert image description here
The member Rotation of Transform in the Inspector panel is the rotation in the local coordinate system, expressed in Euler angle

Transform.Rotate() The local coordinate system and the world coordinate system rotate around a certain axis

This method can be rotated in some axis of 世界坐标系or 本地坐标系, such as

        //1,相对于世界坐标
        transform.Rotate(Vector3.left, Space.World);

        //2,相对于局部坐标,也就是自身坐标
        transform.Rotate(Vector3.forward, Space.Self);

        //3,基本用法
        float speed = 1f;
        Vector3 v3 = new Vector3(10, 10,10);
        transform.Rotate(v3*speed*Time.deltaTime);

Guess you like

Origin blog.csdn.net/qq_22849251/article/details/130428457
Recommended