Transform.eulerAngles 歐拉角


var eulerAngles : Vector3

Description描述

The rotation as Euler angles in degrees.

旋轉作為歐拉角度。

The x, y, and z angles represent a rotation z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

x、y、z角代表繞z軸旋轉z度,繞x軸旋轉x度,繞y軸旋轉y度(這個順序)。

Only use this variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotateinstead.

僅使用者這個變量讀取和設置角度到絕對值。不要遞增它們,當超過角度360度,它將失敗。使用Transform.Rotate替代。

// Print the rotation around the global X Axis
//打印繞世界x軸的旋轉角度
print (transform.eulerAngles.x);
// Print the rotation around the global Y Axis
//打印繞世界y軸的旋轉角度
print (transform.eulerAngles.y);
// Print the rotation around the global Z Axis
//打印繞世界z軸的旋轉角度
print (transform.eulerAngles.z);

// Assign an absolute rotation using eulerAngles
//指定一個絕對使用歐拉角的旋轉角度
var yRotation : float = 5.0;
function Update () {
    yRotation += Input.GetAxis("Horizontal");
    transform.eulerAngles = Vector3(10, yRotation, 0);

}

Do not set one of the eulerAngles axis separately (eg. eulerAngles.x = 10; ) since this will lead to drift and undesired rotations. When setting them to a new value set them all at once as shown above. Unity will convert the angles to and from the rotation stored in Transform.rotation

不要分別設置歐拉角其中一個軸(例如: eulerAngles.x = 10; ),因為這將導致偏移和不希望的旋轉。當設置它們一個新的值時,要同時設置全部,如上所示。Unity會從Transform.rotation這個四元組結構中轉換角度到歐拉角的表達方式,或者反過來。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM