「Unity」將Vector3轉化為Quaternion


重載1:
static Quaternion Euler (float x ,float y,float z)

Description:
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

描述:
返回一個旋轉角度,繞z軸旋轉z度,繞x軸旋轉x度,繞y軸旋轉y度(像這樣的順序)。

具體使用代碼如下:

//將transform中的rotation修改成(0,30,0)
 Quaternion rotation = Quaternion.Euler(0f, 30f, 0f);
 transform.rotation = rotation;

重載2:
static Quaternion Euler (Vector3 rotationVector3)

Description:
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

描述:
返回一個旋轉角度,繞z軸旋轉z度,繞x軸旋轉x度,繞y軸旋轉y度(像這樣的順序)。

具體使用代碼如下:

 //將transform中的rotation修改成(0,30,0)
 Vector3 rotationVector3 = new Vector3(0f, 30f, 0f);
 Quaternion rotation = Quaternion.Euler(rotationVector3);
 transform.rotation = rotation;

原創文章,轉載請注明出

http://www.cnblogs.com/777777-716/p/5003958.html


免責聲明!

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



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