LinMinquan's Blog

Experience technology to change life

Unity3D Quaternion LookRotation FromToRotation SetLookRotation

看到Quaternion的LookRotation函数,没看懂,就研究了一下。

public static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);

Creates a rotation with the specified forward and upwards directions.

Returns the computed quaternion. If used to orient a Transform, the Z axis will be aligned with forward/ and the Y axis with upwards if these vectors are orthogonal. Logs an error if the forward direction is zero.

总结:其实说白了,LookRotation的含义就是,计算让Z轴对齐forward,让y轴对齐upward 所需要的旋转四元数

参考链接:unity3D 彻底搞懂 Quaternion LookRotation FromToRotation SetLookRotation方法

https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html


Share