Get Velocity of actor relative to another actor

The result I am trying to do here is to calculate the collision of two cars and check how badly each of them was affected (to calculate their health).

Getting the momentum was the way to go here. But the problem is that a car (A) could be hitting another car (B) from the rear. So even though Car B was traveling at a high velocity, it shouldn’t impact on Car A (Since B was traveling away from A).

What I would want here is a way for me to calculate the velocity at which Car B is heading towards Car A and not the overall velocity. This should ideally be 0 in the above case.

Will appreciate any help on that. I am also open to alternative methods that could apply in this case.

To get the difference between the two velocity vectors you only have to subtract vector A from vector B. Then you can use the length of the resulting vector to get only the speed difference, which is what you use to calculate damage.

It should be

const float Speed = (CarA->GetMovementComponent()->Velocity - CarB->GetMovementComponent()->Velocity).Size();	

What about comparing previous velocity?
If current velocity is 0 and previous tick is 1000 then you have an impact of 1000.
If current is 800 and previous is 1000 then then impact is only 200.

Thanks. This works. Definitely much simpler than where I was putting my minds.