How to detect velocity of a coliding object

Hello! I am devoloping a game these days.My game is a little spaceship collecting coins and park on a floating horizontal stick.So I want to detect velocity of the spaceship when it colide with the parking slot.If the velocity is higher than certain number ship must be destroyed. Really appreciate your help.Thank you!

Speed = Distance / Time so if you know how far you’ve moved each frame then you should be able to work out the speed.
Note that velocity is speed with a direction, so is a 3-dimensional vector rather than a scalar, and depending on what you want the math is slightly different.

If you’re using a physics engine then most will have a method for working out the velocity or the speed, so you don’t have to work it out yourself.

In something like Unity, you could use Rigidbody.velocity for the velocity, or rigidbody.velocity.magnitude for the speed.

1 Like