Version: 2017.1
public void MoveRotation (Quaternion rot);

Parámetros

rot La nueva rotación para el Rigidbody.

Descripción

Rota el Rigidbody con una rotación rotation.

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 positions 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.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Rigidbody rb; Vector3 newPos = new Vector3(10.0f, 0.0f, 3.0f); float speed = 1.0f;

void Start() { rb = GetComponent<Rigidbody>(); }

// fixedDeltaTime provides the same time that FilterUpdate() uses void FixedUpdate() { if (rb.position.x <= 1.0f) { Vector3 direction = (newPos - transform.position).normalized; rb.MovePosition(transform.position + direction * speed * Time.fixedDeltaTime); } } }

Tele-transporta el objeto (en vez de una transición suave) si tiene isKinematic establecido a falso.

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