Unity中的物体旋转
(1)
物体在对应的坐标系中旋转,默认使用本地坐标系
public void Rotate(Vector3 eulers, Space relativeTo = Space.Self);
public void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo = Space.Self);
物体在对应的坐标系中以axis为轴进行旋转
public void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self);
(2)
在世界坐标系中以point的axis方向为轴进行旋转
public void RotateAround(Vector3 point, Vector3 axis, float angle);
(3)
旋转物体,使物体的Z轴指向target。
worldUp:对象朝向目标后旋转自身,使得worldUp垂直z轴向上
public void LookAt(Transform target);
public void LookAt(Transform target, Vector3 worldUp = Vector3.up);
旋转物体,使物体指向世界坐标系中的一点
public void LookAt(Vector3 worldPosition);
public void LookAt(Vector3 worldPosition, Vector3 worldUp = Vector3.up);
(4)
计算让Z轴对齐forward,让y轴对齐upward 所需要旋转的四元数
public static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);