public void MoveRotation (Quaternion rot);

パラメーター

rotRigidbody の角度

説明

Rigidbody オブジェクトを指定する角度へ回転します

Use Rigidbody.MoveRotation to rotate a Rigidbody, complying with the Rigidbody's interpolation setting.

If Rigidbody interpolation is enabled on the Rigidbody, calling Rigidbody.MoveRotation will resulting in a smooth transition between the two rotations in any intermediate frames rendered. This should be used if you want to continuously rotate a rigidbody in each FixedUpdate.

Set Rigidbody.rotation instead, if you want to teleport a rigidbody from one rotation to another, with no intermediate positions being rendered.

//Attach this script and a Rigidbody to your GameObject. To do this click the GameObject, click the Add Component button in its Inspector, and go to Physics>Rigidbody.

using UnityEngine; using System.Collections;

public class Example : MonoBehaviour { //Make sure you attach a Rigidbody in the Inspector of this GameObject Rigidbody m_Rigidbody; Vector3 m_EulerAngleVelocity;

void Start() { //Set the axis the Rigidbody rotates in (100 in the y axis) m_EulerAngleVelocity = new Vector3(0, 100, 0);

//Fetch the Rigidbody from the GameObject with this script attached m_Rigidbody = GetComponent<Rigidbody>(); }

void FixedUpdate() { Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * Time.deltaTime); m_Rigidbody.MoveRotation(m_Rigidbody.rotation * deltaRotation); } }

isKinematic を false に設定すると、スムーズな推移というよりはむしろオブジェクトはテレポートされます。