Rigidbody.AddExplosionForce

Hi!

I need some help with the example script for Rigidbody.AddExplosionForce. I can’t seem to get it to work… I’m trying to use the explosive force on a ragdoll i just created, after smashing into a NPC with a vehicle…

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);
}
}

I already have this script on the vehicle, generating the ragdoll…

var ragdoll: Transform;

function OnCollisionEnter( collision : Collision) {
  if (collision.relativeVelocity.magnitude > 4.5){
	Destroy (gameObject);
    Debug.Log(collision.relativeVelocity.magnitude );
var theClonedExplosion : Transform;
theClonedExplosion = Instantiate(explosion,
transform.position, transform.rotation);
print(collision.transform.gameObject);
}
}

How do I combine the two scripts, so that the explosion force is used to blow the ragdoll away, without it interfering with the car?

Thanks in advance!

You have the function layed out correctly but you either need the power turned up ( I have it set to 1000 for a small explosion ) or have the radius turned up. Just keep on making them higher and higher until it does something.