I would like to calculate "impact" of collision if its the right word for it. My scenario is: I have player, who is driving his vehicle. He then hits the wall while still in vehicle. I want to know if the collision happend and calculate the impact of collision, so later I know how much hp the player should lose depending how hard the hit was. I hope I made clear what I want to achieve.

What I'm currently doing is storing the previous vehicle speed and calculating the impact like this (previousSpeed - currentSpeed) / frameTime. It gives me some results but it's not consistent. Any other idea? It's in 3D so I have access to 3d vectors if it helps in any way.

  • \$\begingroup\$ Check out this answer (4th post from the top).: forum.unity.com/threads/… \$\endgroup\$ – hatinacat2000 Nov 3 '19 at 0:15
  • \$\begingroup\$ Well it says to calculate the mass of the other colider aswell as the velocity of the other colider. In my case it's wall or anyother non-movable object, so it's velocity is 0 but I don't have mass of the object, and It would be propably stupid to make table of every object mass. \$\endgroup\$ – porqqq Nov 3 '19 at 18:59

I'll take impact as "any consequence".

You are talking about momentum. It is represented by a vector, its value is \$MLT^{-1}\$ dimensionned. It is related to mass and speed this way: \$\vec p=m\vec v\$ where \$\vec p\$ and \$\vec v\$ are vectors. Momentum is conserved in isolated systems (no external force applied), which is the key point to make your calculations; you'll need to add some mass (eg., divide your objects (player) into smaller regions, each having a mass). Momentum is related to force as such: \$\vec ft=\vec p\$ where \$t\$ is time, \$\vec f\$ force vector.

In order to make something realistic you'll also have to set rigid and soft body mechanics (with local mass), including elasticity, and material cohesion (if the momentum is high enough, the material can break or be teared).

A collision is detected as a sudden change of momentum (sudden change of speed).

A bit more here: https://en.wikipedia.org/wiki/Momentum

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.