返回介绍

Rigidbody.MoveRotation 移动旋转

发布于 2019-12-18 15:38:28 字数 2320 浏览 1049 评论 0 收藏 0

JavaScript => public function MoveRotation(rot: Quaternion): void;
C# => public void MoveRotation(Quaternion rot);

Parameters 参数

rotThe new rotation for the Rigidbody.
用于刚体的新旋转。

Description 描述

Rotates the rigidbody to rotation.

旋转刚体到新角度。

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

使用Rigidbody.MoveRotation来旋转刚体,带有刚体的插值设置。

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.

如果刚体插值启用,调用Rigidbody.MoveRotation导致在任意两帧之间平滑过渡。如果你想在每固定更新连续旋转刚体使用这个。

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

如果你想瞬移刚体从一个旋转到另一个旋转使用Rigidbody.rotation替代,中间位置不被渲染。

JavaScript:

var eulerAngleVelocity : Vector3;
var rb: Rigidbody;
 
function Start() {
	rb = GetComponent.<Rigidbody>();
}
 
 
function FixedUpdate () {
	var deltaRotation : Quaternion = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
	rb.MoveRotation(rb.rotation * deltaRotation);
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public Vector3 eulerAngleVelocity;
    public Rigidbody rb;
    void Start() {
        rb = GetComponent<Rigidbody>();
    }
    void FixedUpdate() {
        Quaternion deltaRotation = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
        rb.MoveRotation(rb.rotation * deltaRotation);
    }
}

Rigidbody

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文