Z軸で /eulerAngles.z/ 度回転、X軸で /eulerAngles.x/ 度回転、Y軸で /eulerAngles.y/ 度回転します (順番は説明した順)
/relativeTo/ を設定しない、またはSpace.Selfを設定した場合は回転はTransformのローカル軸で適用されます。(シーンビュー内でオブジェクトを選択している時に見えているX,Y,Z軸) /relativeTo/ がSpace.Worldの場合、回転はワールドのX,Y,Z軸で適用されます。
function Update() {
// Slowly rotate the object around its X axis at 1 degree/second.
transform.Rotate(Vector3.right * Time.deltaTime);
// ... at the same time as spinning relative to the global
// Y axis at the same speed.
transform.Rotate(Vector3.up * Time.deltaTime, Space.World);
}
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Update() { transform.Rotate(Vector3.right * Time.deltaTime); transform.Rotate(Vector3.up * Time.deltaTime, Space.World); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Update() as void: transform.Rotate((Vector3.right * Time.deltaTime)) transform.Rotate((Vector3.up * Time.deltaTime), Space.World)
Z軸で zAngle 度回転、X軸で xAngle 度回転、Y軸で yAngle 度回転します (順番は説明した順)
/relativeTo/ を設定しない、またはSpace.Selfを設定した場合は回転はTransformのローカル軸で適用されます。(シーンビュー内でオブジェクトを選択している時に見えているX,Y,Z軸) /relativeTo/ がSpace.Worldの場合、回転はワールドのX,Y,Z軸で適用されます。
function Update() {
// Slowly rotate the object around its X axis at 1 degree/second.
transform.Rotate(Time.deltaTime, 0, 0);
// ... at the same time as spinning it relative to the global
// Y axis at the same speed.
transform.Rotate(0, Time.deltaTime, 0, Space.World);
}
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Update() { transform.Rotate(Time.deltaTime, 0, 0); transform.Rotate(0, Time.deltaTime, 0, Space.World); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Update() as void: transform.Rotate(Time.deltaTime, 0, 0) transform.Rotate(0, Time.deltaTime, 0, Space.World)
指定した軸(angle)で angle 度回転させます
/relativeTo/ を設定しない、またはSpace.Selfを設定した場合は軸( axis )はTransformのローカル軸で適用されます。(シーンビュー内でオブジェクトを選択している時に見えているX,Y,Z軸)
/relativeTo/ がSpace.Worldの場合、 axis パラメータはワールドのX,Y,Z軸で適用されます。
function Update() {
// Slowly rotate the object around its X axis at 1 degree/second.
transform.Rotate(Vector3.right, Time.deltaTime);
// ... at the same time as spinning it relative to the global
// Y axis at the same speed.
transform.Rotate(Vector3.up, Time.deltaTime, Space.World);
}
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Update() { transform.Rotate(Vector3.right, Time.deltaTime); transform.Rotate(Vector3.up, Time.deltaTime, Space.World); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Update() as void: transform.Rotate(Vector3.right, Time.deltaTime) transform.Rotate(Vector3.up, Time.deltaTime, Space.World)