# Listen for force applied to a rigidbody?

Is there a listener I can use for this? I want to detect when a rigidbody is knocked about by an explosion and apply damage based on the force of the shockwave.

I don't think there is a listener, but here's what I do to determine the amount of movement on an object. Throw this in your update, and apply the damage based on the total movement number multiplied by Time.deltaTime

``````    float combinedSpeed = (Mathf.Abs(this.rigidbody.velocity.x) +
Mathf.Abs(this.rigidbody.velocity.y) +
Mathf.Abs(this.rigidbody.velocity.z));

float combinedAngular = (Mathf.Abs(this.rigidbody.angularVelocity.x) +
Mathf.Abs(this.rigidbody.angularVelocity.y) +
Mathf.Abs(this.rigidbody.angularVelocity.z));

``````

Maybe I misunderstood how to use your code, but I couldn't get it working.

This variation works for me:

``````var combinedSpeed = (Mathf.Abs(this.rigidbody.velocity.x) +
Mathf.Abs(this.rigidbody.velocity.y) +
Mathf.Abs(this.rigidbody.velocity.z));

var combinedAngular = (Mathf.Abs(this.rigidbody.angularVelocity.x) +
Mathf.Abs(this.rigidbody.angularVelocity.y) +
Mathf.Abs(this.rigidbody.angularVelocity.z));

var relativeSpeed = Mathf.Abs(previousSpeed - combinedSpeed);
if (relativeSpeed > damageThreshold) {
currentHealth -= (relativeSpeed - damageThreshold);
}

previousSpeed = combinedSpeed;
previousAngular = combinedAngular;

if (currentHealth < 0) {
var instantiatedExplosion : GameObject = Instantiate(explosion, transform.position, transform.rotation);
Destroy(gameObject);
}

``````