最近在做策划给的一些关于FPS类型的需求,Demo基本已经成型,接下来整理并记录,高手略过,不喜勿喷!!!
手雷扔到目标点爆炸造成的伤害(需要造成伤害的对象身上需要有刚体组件Rigidbody)
/// <summary>
/// 爆炸波及的对象
/// </summary>
/// <param name="radius">半径</param>
/// <param name="point">爆炸点</param>
public void Bomb(float radius, Vector3 point) {
Collider[] others = Physics.OverlapSphere(point, radius);
Rigidbody other;
for (int i = 0; i < others.Length; i++) {
if ((other = others[i].GetComponent<Rigidbody>())) {
other.AddExplosionForce(100, point, radius, 10);
}
}
}