Jumping, sounds and landing

hi,

my character has a double jump, what i wish to happen is the following…

  1. character jumps once = no sound
  2. character jumps once, then a second time in the air = sound
  3. character jumps, lands, then jumps again = no sound
  4. character jumps, lands, doubles jumps = sound

i’ve scorched my brain doing this hopefully someone can fix this

I would reword this, i am struggling on what you need? Are you saying that when he jumps the first time there needs to be no sound then when he jumps again it makes a sound and when he lands it makes a sound? if so just run a check for when the player transitions from falling to walking. When they land play sound and run it on a do once which gets reset after the sound is done.

apologies i will attempt to clarify for you

When the character jumps there should be no sound playing, the character jumps when the player presses spacebar

If the player presses spacebar again while in the air, he will jump again, because the jump allowance is 2 not 1

when the player jumps the second time, i want a sound to play

there is one situation in which there is an issue, which is if a player jumps then lands, then jumps again the sound plays when it shouldn’t because it thinks the second jump is happening but doesn’t know the player has landed and the cycle should reset so if the player jumps and lands no sound, then when the player jumps and lands again there should be no sound because he landed that time so it shouldn’t play the sound

This might be crude, but you can set it on a event tick and then when the players Z velocity hits 0 from after jumping then your can run a trigger that plays the sound once. want an example or na?

Depending on your jump setup, something like this:


(for an input action with a Pressed trigger, will definitely need some reworking otherwise).

But probably with the ‘falling’ check replaced with your own IsJumping flag, which you would need to maintain (set true on jump, then in Tick if its true check movement mode, and if no longer falling set false).

1 Like

it seems a lot cleaner and from i can tell it should work but i still get the sound twice even from the first jump

How is your input action setup?

You may have a Down trigger on it? This will fire every frame you are holding the key down, which may pan out to 2 times (or 1, 3, 4, 5, …) depending on how decisive your keystrokes are.
If that is the case change it to a Pressed trigger and it should work with the graph I posted above.

this tutorial has it working the way I want with a few tweaks, i will show you below

How to Double Jump with Animation In Unreal Engine 5

Your first branch outputs are wired up wrong (as compared to the tutorial), you are playing the montage for the first jump.

Swap those back, skipping the Play Sound node for the true branch, and move the Play Sound down and insert it into the false → true branch(before or after the play montage, which should only be playing on the second jump, not the first).

is this it?

Nope, that’s even worse :stuck_out_tongue_winking_eye:

Try this:

The first time (jump count == 0), just jump and increment count.
subsequent times less than our limit (jump count < 2), jump, increment, play sound + montage.

1 Like

works like a charm thanks mate, although the T-Post montage doesn’t seem to activate

I think the T-Pose animation is only a single frame, could you turn the play rate way down and retest? Might be playing but is over so fast is never renders (or isn’t noticeable).

1 Like

that did it, changing the play rate to 0.05 made it appear, thanks for your brain power <3

1 Like