Collision.relativeVelocity 相对速度

var relativeVelocity : Vector3

Description描述

The relative linear velocity of the two colling objects (Read Only).

两个碰撞物体的相对线性速度(只读)。

using UnityEngine;

using System.Collections;



public class example : MonoBehaviour {

	void OnCollisionEnter(Collision collision) {

		if (collision.relativeVelocity.magnitude > 2)

			audio.Play();



	}

}
// Play a sound when we hit an object with a big velocity

//当以一个较大的速度碰到物体时,播放声音

function OnCollisionEnter(collision : Collision) {

	if (collision.relativeVelocity.magnitude > 2)

		audio.Play();

}
Page last updated: 2010-12-18