言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Transform.Rotate

Switch to Manual
public function Rotate(eulerAngles: Vector3, relativeTo: Space = Space.Self): void;

Description

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);
	}
public function Rotate(xAngle: float, yAngle: float, zAngle: float, relativeTo: Space = Space.Self): void;

Description

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);
	}
public function Rotate(axis: Vector3, angle: float, relativeTo: Space = Space.Self): void;

Description

指定した軸(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);
	}