Hi,
Can I use add explosion force but constrain it to two axis for the purposes of 2D explosion physics. Or is there a better way for achieving this? What I want is to affect rigidbodies near a gameobject by applying relative force based on distance from explosion centre, and the power of the explosion. Do I put this on the projectile or instantiate a seperate explosion gameobject?
var radius = 5.0;
var power = 10.0;
function Start () {
// Applies an explosion force to all nearby rigidbodies
var explosionPos : Vector3 = transform.position;
var colliders : Collider = Physics.OverlapSphere (explosionPos, radius);
for (var hit : Collider in colliders) {
if (!hit)
continue;
if (hit.rigidbody)
hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0);
}
}