1234567891011121314151617181920 |
- namespace UnityEngine
- {
- internal static class VectorUtils
- {
- /// <summary>
- /// 向量按Y轴向左旋转
- /// </summary>
- /// <param name="vector"></param>
- /// <param name="degrees">正值代表向左、逆时针</param>
- /// <returns></returns>
- public static Vector3 RotateLeft(this Vector3 vector, float degrees)
- {
- //创建一个表示Y轴旋转的四元数,正值代表向左旋转(逆时针)
- // 飞龙的地图是沿着Y轴向上的,角度需要改成z轴
- Quaternion rotation = Quaternion.Euler(0, 0, degrees);
- //使用四元数旋转向量
- return rotation * vector;
- }
- }
- }
|