Rigidbody.velocity 速度

var velocity : Vector3


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);
Page last updated: 2011-1-29