Best way to do fall damage/impact damage

The title says it all, what’s the best way to do fall damage? In a, realistic way.

I’m aware there’s already a thread on this, but the two ways they explained how to do it on that thread:

Setting a timer when a player has started falling. Then reducing health accordingly. Which seems like a bad idea, because if there’s any lag, fall damage could do more than normal. And if you ever stop mid-air, the timer could return an inaccurate result.

Using a player part and grabbing the velocity of the part when they hit the ground, then reducing health accordingly. Which I found to be pretty inaccurate, for some odd reason. Velocity for me seems to just go haywire, and doesn’t seem reliable.

Not said in that topic, but a third way to do it:

  1. Getting position of when you jumped, then getting position of where you landed. And subtracting the values, and reducing health depending on that. Or even more accurate, getting the highest point after jumping. Just in case you happen to fly up with an ability or something, I dunno. But then, even if you slowed down before your fall, it doesn’t matter.

I’m not asking for a script, I’m just asking for the logic behind a system.

There really seems to be a lack of discussion on this topic, it’s odd. So, any ideas would be appreciated. Thanks.

2 Likes

I personally would use the third method. This is the most accurate/best way in my opinion, since it uses distance instead of falling time (which doesn’t account for acceleration/terminal velocity/gravity/etc). That being said, lag shouldn’t be a huge issue if you were to use the first method.

2 Likes

Yeah I’m now realizing that would be the best option. Thanks for the feedback though.

I’m tempted to delete the thread now… but I guess I’ll set your answer as the solution to help any other people having the same issue.

Also I dunno if you can delete threads or not ;/

1 Like

Third method is good unless the player has something like a parachute that might slow them to a speed where they should be safe or something like that. The second method is probably the best. My guess to the issue you are having with method 2 is the way you get it might only be saving the velocity after it has already been corrected by hitting the ground surface for landing, or that the short instant where the player is correcting themselves for clipping into the ground (the little upward bounce you will notice when jumping down) is the velocity you are saving.

These are only guesses, but in my experience the falling velocity is accurate at least before you hit the ground. Maybe when the player is in the air you could save the velocity from the last handful of physics steps to a table, then when you detect a landing you can compare them to see which velocity the landing happened on. Then use the velocity from the step before that to determine the damage. If that works then it should be the most robust and future-proof solution of the three.

Edits for clarity

1 Like

Upon thinking about this more I realize that you could always just be using the velocity and looking for abrupt changes. When an abrupt change occurs you could check the change in the Y value or even for the whole magnitude of the velocity if you want slamming into walls to damage the player. Then, using that change in speed you can decide if you want to do damage. I haven’t tried this myself yet but I think this approach would have a lot of flexibility to tell the game when you do and don’t want to hurt the player. Let me know if you try it out. I wanna know if it works well.

2 Likes