Version: 2018.1
public void MoveRotation (Quaternion rot);

Parameters

rotВращение твердого тела.

Description

Вращает твердое тело к вращение.

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); } }

Teleports the object (rather than a smooth transition) if it has isKinematic set false.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961