Quaternion.LookRotation
public static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);
参数说明:
forward: The direction to look in.
upwards: The vector that defines in which direction up is.
理解这个函数,重点是理解以上两个参数的说明:
什么叫look in :
指的是,该向量为在世界坐标系中,旋转本体需要最终(面朝大海那个朝向)朝向的那个方向。
什么叫 in which direction up is:
指的是,旋转本体要知道对自己来讲,哪个是“上”。旋转本体在该旋转中,要确保自己的x轴与Vector.up垂直。如果原来不是垂直,就修正过来。
一般情况下,Vector3.up都是OK的。但也存在部分情况,比如一些影片航拍时需要摄像头(旋转本体)绕Z轴旋转,出现“天旋地转”的效果,那么该函数第二个参数不能是Vector.up了。
另有一篇别人写得很详细的分析:
http://blog.csdn.net/lijing_hi/article/details/7272089
Unity中 Quaternion.LookRotation函数理解
