之前寫過一篇關於萬向節鎖的文章(http://blog.csdn.net/lj820348789/article/details/48264049),當然,那都是理論上的,下面來看看在實戰中遇到的萬向節鎖問題,代碼如下:
public class Rotation : MonoBehaviour {
// Use this for initialization
void Start () {
this.transform.rotation = Quaternion.AngleAxis(10, new Vector3(1, 0, 0));
this.transform.rotation = Quaternion.AngleAxis(90, new Vector3(0, 1, 0)) * transform.rotation;
this.transform.rotation = Quaternion.AngleAxis(100, new Vector3(0, 0, 1)) * transform.rotation;
}
// Update is called once per frame
void Update () {
}
}
運行之後,得到如下結果:
可以看到,z軸向是沒有旋轉的。