找回密碼
 注冊帳號

掃一掃,訪問微社區

collider.oncollisionexit 退出碰撞

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

摘要: collider.oncollisionexit 退出碰撞functiononcollisionexit(collisioninfo:collision) : voiddescription描述oncollisionexit is called when this collider/rigidbody has stopped touching another rigidbody/col ...

collider.oncollisionexit 退出碰撞

functiononcollisionexit(collisioninfo:collision) : void

description描述

oncollisionexit is called when this collider/rigidbody has stopped touching another rigidbody/collider.

當 collider/rigidbody停止觸動另一個 rigidbody/collider時,oncollisionexit被調用。

in contrast to ontriggerexit, oncollisionexit is passed thecollisionclass and not a collider. thecollisionclass contains information about contact points, impact velocity etc. if you don't use collisioninfo in the function, leave out the collisioninfo parameter as this avoids unneccessary calculations. note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.

相比ontriggerexit,oncollisionexit傳遞collision類而不是collider。collision類包含接觸點,碰撞速度等信息。在這個函數如果你不使用collisioninfo,刪去collisioninfo參數以避免不必要的計算。注意,當其中至少一個碰撞盒附加非動力學剛體時碰撞事件才會發送。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

void oncollisionexit(collisioncollisioninfo) {

print("no longer in contact with " + collisioninfo.transform.name);

}

}

function oncollisionexit(collisioninfo :collision) {

print("no longer in contact with " + collisioninfo.transform.name);

}

相關閱讀

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