找回密码
 注册帐号

扫一扫,访问微社区

collider.closestpointonbounds 到边界框最近点

2015-1-4 16:47| 发布者: 杨炎| 查看: 2873| 评论: 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;

}

相关阅读

文章点评
相关文章