Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Transform.rotation

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public var rotation: Quaternion;
public Quaternion rotation;

説明

Quaternion として保存されるワールド空間での Transform の回転

Unity は内部的に Quaternions として回転を保存します。オブジェクトを回転させるには Transform.Rotate を使用します。 オイラー角のような回転値を設定したい場合は Transform.eulerAngles を設定してください。

	// Reset the world rotation
	transform.rotation = Quaternion.identity;
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { transform.rotation = Quaternion.identity; } }

他の例

// Smoothly tilts a transform towards a target rotation.
var smooth = 2.0;
var tiltAngle = 30.0;
function Update () {
	var tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
	var tiltAroundX = Input.GetAxis("Vertical") * tiltAngle;
	var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
	// Dampen towards the target rotation
	transform.rotation = Quaternion.Slerp(transform.rotation, target,  Time.deltaTime * smooth);
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public float smooth = 2.0F; public float tiltAngle = 30.0F; void Update() { float tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle; float tiltAroundX = Input.GetAxis("Vertical") * tiltAngle; Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ); transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth); } }