Download

How to tell (in seconds) how long Is Falling is activated?

I have went through many tutorials and even the infamous “simple fall damage” thread here. But I have not found the solution yet. I want to take a character that “is falling”, and if is falling for at least say 3 seconds, then several options can be utilized, like…play an animation (skydive, free fall etc), play a sound (air rushing sound), and then call for example the space bar (normally the jump key) to activate a parachute.

I imagine this is probably ez considering UE4 has the built in Is Falling function.

I’m just looking for a direct value in seconds.

Any ideas are much appreciated, thanks.

You have to time it. When they start falling, start the timer.

considering UE4 has the built in Is Falling function

It may be worth noting that:

image

Does not actually do what it says on the tin at all (the tooltip explains it somewhat better). You might be jumping up and not actually falling down and the above would still return True. Judging by the really :cool: diagram, we’re talking gravity here so you may want to monitor velocity instead:

image

And then start counting time with the preferred method.


But perhaps being shot from a cannon up & away, and gaining altitude for 3s should still count as falling and the player would assume their free-fall pose even when going up. Then isFalling should be more than OK.

You could also make make detecting the desired state falling / velocity agnostic and fiddle with Jumping only:

But that would not work too well when walking off a ledge.

How?

Yes indeed. So I was looking for a way to turn the built in function into something that could interact with a timer. What I tried to do was use a delay for the 3 seconds (set to 2 just for testing purposes. I made a macro but can’t seem to get it to work or even print string. I’m clearly doing something wrong.

I worked a parachute tutorial off of youtube and got that to work. The tutorial chooses the “F” key to deploy chute and the “T” key to cut it loose and reset OR it will reset and destroy actor anyway as soon as the player lands.

What I am looking for in that regard is being able to have a boolean condition for a branch to ask essentially “Is player in freefall?” and if so, then allow input from the spacebar (same spacebar used for jump in 3rd person template) to activate the chute. But this time it would just be calling the spacebar key itself and not an action input.

Thanks for the help.

Tried some more stuff tonight but still can’t seem to get that branch before the parachute code to know if player is in the air 2-3 seconds. I don’t know what I’m missing here. Any help is appreciated. Thanks.

You could try it like this:


Also, the Handle can do much more, for example:

You could read data off it if you so prefer.


You can also use this:

image

Or even add milliseconds together, like in the olden days :wink:

Thanks again for the help! You nailed it exactly in that video. That is good to know about what else the timer handles can do. And good news, I was able to get it working! However, when the character lands and I press the space bar (jump), it doesn’t repeat the process again. Rather the chute opens on the ground and the player shoots up into the air.

And I was able to add a sound to the parachute. So the boolean at that branch I spoke of before the chute does work right. At least once. But then when trying again it does not until I replay the game. I tried swapping some events around (event begin play, event tick) in the “do once” nodes and, so far It seems very touchy to mess with those.

Although it is probably beyond the scope of this thread, I think I need to post a pic of the chute code because I’m getting an error after every run that comes as a result of “destroying actor” and it seems a fairly common error that is usually fixed with “Is Valid” but I have no luck on that yet.

The wires overlap too much for me to figure out what’s needed. There’s nothing plugged into isValid so that’s always False. Perhaps you could briefly describe how it’s supposed to work. So far we’ve got:

  • player jumps off a cliff and gravity kicks in
  • we count the time they’ve been falling for
  • once we reach the time threshold, we enter a free-fall mode (so we can open the parachute now? or no?)
  • when is the parachute supposed to deploy? is this automatic? separate key?
  • it seems it’s spawned after we jump providing the freefall is True
  • but jumping and deploying the parachute are the same input button?
  • at some point the chute gets destroyed (it seems you try to access it after it was destroyed, hence the error)

Could you walk us through the desired logic step-by-step.

Although it is probably beyond the scope of this thread

On the contrary, I’d like to very much see where this is going!

If you’re doing a BR deploy, go with States. On spawn set state to freefall. Use periodic line traces to get distance to ground. Use a Min height for auto chute and a max height for enabling chute (space bar).

For other scenarios I’d look at “OnMovementModeChanged”. Check if mode is Falling, Then line trace to ground. If Distance greater than n (possible to freefall etc) set timer → init freefall and so forth.

Here’s a lil BP to explain.

1 Like

“player jumps off a cliff and gravity kicks in”
Yes just like the standard third person template.

“we count the time they’ve been falling for”
That was accomplished. Now just trying to make it go again everytime after the player touches the ground. Not just once per play.

“once we reach the time threshold, we enter a free-fall mode (so we can open the parachute now? or no?)”
Exactly…I guess you could think of it as an additional state, its not just is falling, but is falling+ In that freefall state the player could go into skydiving mode., and yes chute is viable after that not before.
“when is the parachute supposed to deploy? is this automatic? separate key?”
After the player has reached desired time. I did some checking and this seems to be somewhere between 1 /12 to 3 seconds.
“it seems it’s spawned after we jump providing the freefall is True”
Yes
“but jumping and deploying the parachute are the same input button?”
Yes
“at some point the chute gets destroyed (it seems you try to access it after it was destroyed, hence the error)”
The tutorial I worked to make it had the “T” as a means to cut chute and immediately destroy actor, also the actor is destroyed on is landed.

“On the contrary, I’d like to very much see where this is going!”

“Could you walk us through the desired logic step-by-step.”

It is not too complicated really. It is mainly just Is Falling timed, that can be used to trigger things.

Your video and my first pic in this thread basically explain it. Essentially when the player steps off of something they fall down as they normally would, but, if they fall past that time set they then have the option for chute with sound (and possibly animations for player and chute). If the player does NOT open the shoot, then they are in freefall status and essentially skydiving like mode.

But whenever player lands on a surface…aka is landed, the whole process starts again the next time they walk off something.

I suppose unless the timer is set to say 3+ plus seconds the effect is not very obvious. I got the animation to play, just things need to be tweaked.

That was sort of what I was trying to do originally when I made this thread. Your BP’s have really helped me, thank you.

just need to tweak it out a bit for times. I’d probably add a distance based case statement.

d between a,b → etc etc

I was finally able to achieve the effect I was after. Thanks all that helped and chimed in.

I ended up making two MACROs, one for the parachute and one for freefall.

The mesh that I used in the video is from a parachute kit I purchased at Epic store awhile back. Skydive and Parachute Kit in Animations - UE Marketplace

However, there is a free parachute tutorial online that I worked in this blueprint, and it uses a free chute mesh from Sketchfab I believe it was. How To Make A Parachute Unreal Engine 4 - YouTube

There is probably better and easier ways to achieve this effect but I am still fairly new to UE, what I wanted was a “freefall” status with animation and sound after X amount of time, and allow the player to press the same “jump” key while in this status to activate a chute.

Hope this helps anyone looking to create something similar.

1 Like