Collision.rigidbody 刚体

var rigidbody : Rigidbody

Description描述

The Rigidbody we hit (Read Only). This is null if the object we hit is a collider with no rigidbody attached.

我们碰撞的刚体(只读)。如果我们碰撞的物体是一个没有附加刚体的碰撞器,返回null。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnCollisionStay(Collision collision) {
		if (collision.rigidbody)
			collision.rigidbody.AddForce(Vector3.up * 15);

	}
}
// Make all rigidbodies we touch fly upwards
//使我们接触的全部刚体向上飞
function OnCollisionStay(collision : Collision) {
		// Check if the collider we hit has a rigidbody
		//检查如果我们接触的碰撞器是一个刚体
		// Then apply the force
		//然后应用力。
		if (collision.rigidbody) {
			collision.rigidbody.AddForce (Vector3.up * 15);
	}
}
Page last updated: 2010-12-18