[Unity知识点整理]关于旋转

来源:互联网 发布:绑架恐怖分子家属 知乎 编辑:程序博客网 时间:2024/05/17 09:05

一、Transform.Rotate :
1.void Rotate(Vector3 eulerAngles, Space relativeTo = Space.Self);

示例:
transform.Rotate(Vector3.right * Time.deltaTime); 绕自身X轴旋转
transform.Rotate(Vector3.up * Time.deltaTime, Space.World); 绕世界Y轴旋转

2.void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo = Space.Self);

示例:
transform.Rotate(Time.deltaTime, 0, 0);绕自身X轴旋转
transform.Rotate(0, Time.deltaTime, 0, Space.World); 绕世界Y轴旋转

3.void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self);按照angle度围绕axis轴旋转变换。

示例:
transform.Rotate(Vector3.right, Time.deltaTime);绕自身X轴旋转
transform.Rotate(Vector3.up, Time.deltaTime, Space.World);绕世界Y轴旋转

二、Transform.RotateAround 围绕旋转
void RotateAround(Vector3 point, Vector3 axis, float angle); 围绕世界坐标的point点的axis旋转该变换angle度。
示例:
transform.RotateAround(Vector3.zero, Vector3.up, Time.deltaTime);

三、
Transform.rotation 旋转角度
Quaternion rotation;变换的旋转,在世界坐标空间储存为四元数。

Quaternion.Euler 欧拉
public static Quaternion Euler(float x, float y, float z);

Quaternion rotation = Quaternion.Euler(new Vector3(0, 30, 0));

原创粉丝点击