# Collision impact force

Hi,

I want to know how to get the impact force between 2 objects.
There’s a algorithm or a method that do it for me?

I know that the force is mass * velocity, but how can I know the velocity at a direction?

Thanks!
Borgo.

EDIT: I’m making a 2D game, so, I will use only the x and y axis.
If I do something like this is correct?:

``````impact = (a.velocity.x - b.velocity.x);
impact += (a.velocity.y - b.velocity.y);
impact *= a.mass*b.mass;

when
a = objecta.rigidbody
and
b= objectb.rigidbody
``````

Thanks again.

I have done!!
I will share:

Edit: code corrections;

``````var impactVelocityX = rigidbody.velocity.x - contact.otherCollider.rigidbody.velocity.x;
impactVelocityX *= Mathf.Sign(impactVelocityX);
var impactVelocityY = rigidbody.velocity.y - contact.otherCollider.rigidbody.velocity.y;
impactVelocityY *= Mathf.Sign(impactVelocityY);
var impactVelocity = impactVelocityX + impactVelocityY;
var impactForce = impactVelocity * rigidbody.mass * contact.otherCollider.rigidbody.mass;
impactForce *= Mathf.Sign(impactForce);
``````

Thanks!