Rigidbody.velocity 速度

var velocity : Vector3

Description描述

The velocity vector of the rigidbody.

刚体的速度向量。

In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour. Don't set the velocity of an object every physics step, this will lead to unrealistic physics simulation. A typical example where you would change the velocity is when jumping in a first person shooter, because you want an immediate change in velocity.

在大多数情况下,你不应该直接修改速度,因为这会导致不真实的行为。在每个物理步,不要再每个物体的速度,这将导致不真实的物理模拟。一个典型的例子,当你在第一人称射击游戏中使用跳跃的时候改变速度,因为你想立即改变速度。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void FixedUpdate() {
		if (Input.GetButtonDown("Jump"))
			rigidbody.velocity = new Vector3(0, 10, 0);

	}
}
function FixedUpdate () {
	if (Input.GetButtonDown ("Jump")) {
		rigidbody.velocity = Vector3(0,10,0);
	}
}
最后修改:2011年1月29日 Saturday 15:47

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。