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

スクリプト言語

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

Transform.eulerAngles

Switch to Manual
public var eulerAngles: Vector3;

Description

オイラー角としての角度

x,y,zの角度は、z軸にz度、x軸にx度、y軸にy度の順に回転します。 この変数は読み込んだり、絶対値の角度を設定する時のみ使用してください。角度が360度を超えた時には失敗するのでインクリメントしないようにしてください。 代わりにTransform.Rotateを使用してください。

	// Print the rotation around the global X Axis
	print (transform.eulerAngles.x); 
	// Print the rotation around the global Y Axis
	print (transform.eulerAngles.y); 
	// Print the rotation around the global Z Axis
	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);
		
	}

(eulerAngles.x = 10; のように)eulerAnglesの一部だけ値を設定することはドリフトと予期せぬ回転につながるのでしないでください。 新しい値を設定するときは、上記のように一度にすべてを設定します。 Unityは Transform.rotation に格納されている回転から角度を変換します。