Transform.Rotate 旋转
function?Rotate?(eulerAngles?:?Vector3,?relativeTo?:?Space?=?Space.Self) : void
Description描述
Applies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order).
應用一個歐拉角的旋轉角度,eulerAngles.z度圍繞z軸,eulerAngles.x度圍繞x軸,eulerAngles.y度圍繞y軸(這樣的順序)。
If relativeTo is left out or set to?Space.Self?the rotation is applied around the transform's local axes. (The x, y and z axes shown when selecting the object inside the Scene View.) If relativeTo is?Space.World?the rotation is applied around the world x, y, z axes.
如果相對于留空或者設置為Space.Self?旋轉角度被應用圍繞變換的自身軸。(當在場景視圖選擇物體時,x、y和z軸顯示)如果相對于?Space.World?旋轉角度被應用圍繞世界的x、y、z軸。
function Update() {// Slowly rotate the object around its X axis at 1 degree/second.//沿著x軸每秒1度慢慢的旋轉物體transform.Rotate(Vector3.right * Time.deltaTime);// ... at the same time as spinning relative to the global// Y axis at the same speed.//相對于世界坐標沿著y軸每秒1度慢慢的旋轉物體transform.Rotate(Vector3.up * Time.deltaTime, Space.World); }? function?Rotate?(xAngle?: float,?yAngle?: float,?zAngle?: float,?relativeTo?:?Space?=?Space.Self) : void
Description描述
Applies a rotation of zAngle degrees around the z axis, xAngle degrees around the x axis, and yAngle degrees around the y axis (in that order).
應用一個旋轉角度,zAngle度圍繞z軸,xAngle度圍繞x軸,yAngle度圍繞y軸(這樣的順序)。
If relativeTo is left out or sot to?Space.Self?the rotation is applied around the transform's local axes. (The x, y and z axes shown when selecting the object inside the Scene View.) If relativeTo is?Space.World?the rotation is applied around the world x, y, z axes.
如果相對于留空或者設置為Space.Self?旋轉角度被應用圍繞變換的自身軸。(當在場景視圖選擇物體時,x、y和z軸顯示)如果相對于?Space.World?旋轉角度被應用圍繞世界的x、y、z軸。
function Update() {// Slowly rotate the object around its X axis at 1 degree/second.//圍繞x軸每秒1度,慢慢的旋轉物體transform.Rotate(Time.deltaTime, 0, 0);// ... at the same time as spinning it relative to the global// Y axis at the same speed.//相對于世界坐標,圍繞y軸每秒1度,慢慢的旋轉物體transform.Rotate(0, Time.deltaTime, 0, Space.World); }? function?Rotate?(axis?:?Vector3,?angle?: float,?relativeTo?:?Space?=?Space.Self) : void
Description描述
Rotates the transform around axis by angle degrees.
按照angle度圍繞axis軸旋轉變換。
If relativeTo is left out or set to?Space.Self?the axis parameter is relative to the transform's local axes. (The x, y and z axes shown when selecting the object inside the Scene View.) If relativeTo is?Space.World?the axis parameter is relative to the world x, y, z axes.
如果相對于留空或者設置為Space.Self?旋轉角度被應用圍繞變換的自身軸。(當在場景視圖選擇物體時,x、y和z軸顯示)如果相對于?Space.World?旋轉角度被應用圍繞世界的x、y、z軸。
function Update() {// Slowly rotate the object around its X axis at 1 degree/second.//圍繞x軸每秒1度,慢慢的旋轉物體 transform.Rotate(Vector3.right, Time.deltaTime);// ... at the same time as spinning it relative to the global// Y axis at the same speed.//相對于世界坐標,圍繞y軸每秒1度,慢慢的旋轉物體 transform.Rotate(Vector3.up, Time.deltaTime, Space.World); }?
轉載于:https://www.cnblogs.com/vincentDr/p/3678342.html
總結
以上是生活随笔為你收集整理的Transform.Rotate 旋转的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 单行文字不断向上滚动特效
- 下一篇: Input.GetAxis 获取轴