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

スクリプト言語

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

Quaternion.RotateTowards

マニュアルに切り替える
public static Quaternion RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta);

パラメーター

説明

from から to への回転を得ます。

クォータニオン from は、maxDegreesDelta の角度の手順で to に回転します (ただし、回転しすぎることはできません)。 maxDegreesDelta の値に従うと、回転がちょうど反対の方向になるまで、to から離れることになります。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; public float speed; void Update() { float step = speed * Time.deltaTime; transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, step); } }