手雷扔到目标点爆炸形成的伤害(须要形成伤害的对象身上须要有刚体组件Rigidbody)ide
/// <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); } } }