So I am currently trying to achieve adding a system where anyone in a vehicle will take damage after crashing their vehicle (or landing too hard on a bike)
I am wondering what the best approach to this would be? My first thoughts was to save the current velocity of the last few frames and check for a sudden stop, but is this the best way?
Personally I would do what you were doing already. Generally you’ll want to test velocity on a per-frame basis. One option is to exclusively use magnitude but in the event that the player manages to bounce off of a wall and starts moving the other way, the magnitude may not be the same (imagine he’s moving at 100 studs/sec towards a wall, hits the wall and bounces backwards at 70 studs/sec, the difference would be 30 studs/sec rather than 100 studs/sec).
My suggestion is to use a mix of velocity and dot product to detect these changes. Sudden direction changes should warrant damage as well on top of suddenly stopping. You could specify a threshold for how drastic the change might be. You should store the last direction (Velocity.Unit of the last frame) and current direction and get the dot product of those two. If the player bounces off of the wall, the dot product will be equal to or very close to -1, meaning the direction suddenly reversed. If it’s a sudden stop it could be a value like 1 or 0 (since the movement may still very slightly be forward), so this is where checking magnitude is handy.
Otherwise, yes, I think your current idea is on track.