找回密碼
 注冊帳號

掃一掃,訪問微社區

collider.closestpointonbounds 到邊界框最近點

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

摘要: collider.closestpointonbounds 到邊界框最近點functionclosestpointonbounds(position:vector3description描述the closest point to the bounding box of the attached collider.到附加碰撞器的邊界框最近的點。thi ...

collider.closestpointonbounds 到邊界框最近點

functionclosestpointonbounds(position:vector3

description描述

the closest point to the bounding box of the attached collider.

到附加碰撞器的邊界框最近的點。

this can be used to calculate hit points when applying explosion damage.

當應用于爆炸傷害,這能用于計算傷害點數。

var hitpoints : float = 100.0;

function applyhitpoints (explosionpos :vector3, radius : float) {

// the distance from the explosion position to the surface of the rigidbody

//從爆炸點到剛體表面的距離

var closestpoint :vector3= collider.closestpointonbounds(explosionpos);

var distance : float = vector3.distance(closestpoint, explosionpos);

// the hit points we apply fall decrease with distance from the hit point

//傷害點數,我們使到傷害點距離減少

var hitpoints : float = 1.0 - mathf.clamp01(distance / radius);

// this is the final hitpoints we want to apply. 10 at maximum

//這是我們想要的最終傷害點數為10

hitpoints *= 10;

}

相關閱讀

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