Simple Fall Damage

I’m sure there are alternatives to create fall damage but here is how I did it.

Create the following floats:
Health (set to 100)
FallDamage
StartAirTime
EndAirTime
ZeroOut (set to 0)

Create the following bools:
IfFallDamage?

Go into your Character blueprint.

Setup the following:


Here you are setting StartAirTime to the elapsed game time when your character jumps.


When your character lands we set EndAirTime to the elapsed game time. We then need to find out if the time our character has been in the air is long enough to incur damage. I want to incur damange when my character has been in the air for over 1.5 seconds, so we subtract StartAirTime from EndAirtime and see if the result is greater than 1.5. If the result is greater than 1.5 we set IsFallDamage to true.

We want to damage our character on a sliding scale so that the longer our character is falling the more damage our character will incur when it lands. So we set FallDamage to the result we got from subtracting StartAirTime from EndAirTime.

We then set both StartAirTime and EndAirTime to ZeroOut to prepare for the next time we run this sequence.


We then check if IsFallDamage? is true or not, printing out NoFallDamage if false and dealing damage to our character if true. If true we subtract FallDamage from Health and then set Health as the result. We then print out our current Health value to the screen.

That is it! Very simple set up that you can then plug into your HUD or whatever.

Hope this helps someone :slight_smile:

+1 Appreciate you taking the time to show us this.

This looks awesome! Thank you for sharing. Any thoughts on how to handle falling into water?

Nice! Good tut.

thanks :smiley: helps alot of people

Thank you very much for this. I was able to use this as a base and modified it so that it was triggered when ever the player was in the air and not just when you jump. Thanks again :slight_smile:

Wow, that’s a nice and straight-forward explanation. Thank you!

falling damage in real life is caused by a sudden change in velocity, not prolonged exposure to air time. your system would not work so well if a player was launched up to a high platform. even though they land softly on the platform because its at the peak of their jump, they might die from being in the air for too long, which would look weird. also, since your method is based on the player jumping, it would not work for situations where the player walked off a ledge without jumping.

here is another way to handle fall damage detection, based on change in speed:

Onicypher is correct. That is the usual way games handle this type of damage event.
I like to apply damage based on Z(abs) velocity divided by half the value of gravity, like that the player usually will die when falling from around 20 meters high or get equivalent damage; the bigger the fall the bigger the damage taken.

I like to apply damage based on good stuff and proper programming as well. However, I can see what Onicypher is doing here but I have no clue is some of this stuff is referred to elsewhere in his blueprint or if the Boolean variables or only set for that portion because I recreated all of this image here and not a darn thing happened and it has me even more confused then when I started.

Bruno can you post an example of your method?

Just a quick question, what would I need to set the value of Delta Speed and some of the other variables to?

Maybe with the “IsFallDamage” you can disable falling damage if you collide with a water object?

ScottSpadea sorry to bring up this old thread but im currently trying to do your fall damage for my college project and i have no clue what the node is that has walking in it…

It’s checking the Movement mode of the pawn.

If you scroll through the Class Defaults of the pawn you’ll see a section dedicated to how the character behaves in specific movement modes (ie, walking, swimming, flying, etc)
The node in the screenshot is checking for to see if the movement mode = “walking”.

Nice and simple Thanks

Use triger for disable

It’s nice but what if you character is hanging from a rope or dangling his legs on a ledge, the air time will be too long unless you reset it when doing that action

I’m trying to understand the Blueprint stuff, but It seems that at the top left the previous velocity is subtracted from current velocity and the the result multiplied with itself then vector broken and each of the xyz params added to each other, while after the subtraction result there is a redundant (not used) VectorLength node… is there a cleaner version of this?

PS.

Also, if you get the “VectorLengthSquared” from “Velocity” of CharacterMovement, you get the same value as all of those calculations…