Ive made a fall damage system however it has some bugs (ITS A LONG ONE)

My fall damage system works by calculating the height using a line trace from the capsule component to the ground connected to the event tick. Storing it in the float variable “Character Height”

Then that value is used when the movement mode is changed to a falling state.

And it starts calculating the damage through the function which is probably not the most efficient. And stores the damage in another float called “TmpDmg”.

Then again connected to the event tick is the “Freefall” custom event which calculates is the z velocity is less than 0 and the character is falling connected to the branch which if true connects to a do once and another branch checking if the height is over 1500 and if its true, plays a falling animation montage. THEN on even landed it finally applies the damage stored in TmpDmg and then sets it to 0 again then resetting the do once.

NOW THE PROBLEM


when the line trace detects the height before jumping, after the character jumps it applies the damage (i know how to fix this). HOWEVER when i jump off the platform there is no damage applied on landed since the death animation is played on death.

pls help thx :slight_smile:

I didn’t look at this in much detail, but should this

image

be this?

what do you mean by the distance variable. Is it the character height? or height trace length

It’s the Z in this variable

image

If the capsule is leaning for some reason, just using a fixed Z won’t do the trick.

Also, you could do the damage like

Not exactly the same, but similar… :slight_smile:

So Ive done both these things, am i supposed to plug the output of the function falling damage into the apply damage on event on landed because Ive done that and exactly the same thing happens.

That’s because the order of events is wrong. You need to apply the damage, and THEN only play the montage is the player is dead.

Are you calling FreeFall on tick?

When you apply damage, should it get subtracted from player health?

Then when player health < 0 → DoOnce → Play montage

1 Like

To add a bit: IMO you should ditch the trace.

1 Like

Seconded. It seems overcomplicated atm and, knowing life, complexity will get out of hand sooner rather than later.


@Simolitical If it’s not too late, consider another approach:

It takes walking off the edges into account, min height damage clamping and jump apex; it’s based on this curve:

Here the initial 200uus deals no damage but Landing from 610 uus would deal 75dmg. You’d need to add the montage or some other bits but the damage dealing works with this script alone and is quite flexible.

Good luck!

2 Likes

OnLaunched too!

Apex

1 Like

thanks a lot i cant believe it was that simple

If i want to add an anim montage of a falling animation from a specific height, i used this:


however every time i jump it triggers the animation. I believe its because we are finding out the z coordinate from the origin 0 and not from the floor underneath. Could you help me find a solution.

You will need check the distance more often. You could use Tick or a Timer - 10x per second is probably plenty:

image

You could use a trace like before but a timer is somewhat easier to control:

This would trigger once we’ve fallen 500uus.


If i want to add an anim montage of a falling animation from a specific height

Not sure if I understood this right, though. The animation triggers at specific height rather than once we’ve fallen a specific distance?

There’s yet another option to make it time based, have a look:

There’s a cool diagram at the top of this thread.

Thank you for everything, this is what ive come up with in the end.
fd posted by Simon.Oko | blueprintUE | PasteBin For Unreal Engine

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.