找回密碼
 注冊帳號

掃一掃,訪問微社區

collision.rigidbody 剛體

2015-1-4 19:47| 發布者: 楊炎| 查看: 1830| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: collision.rigidbody 剛體varrigidbody:rigidbodydescription描述therigidbodywe hit (read only). this is null if the object we hit is a collider with no rigidbody attached.我們碰撞的剛體(只讀)。如果我們 ...

collision.rigidbody 剛體

varrigidbody:rigidbody

description描述

therigidbodywe hit (read only). this is null if the object we hit is a collider with no rigidbody attached.

我們碰撞的剛體(只讀)。如果我們碰撞的物體是一個沒有附加剛體的碰撞器,返回null。

c#

javascript

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);

}

}

相關閱讀

文章點評
相關文章
女校游泳队彩金