Infinite sound when jumping

I have added a sound for the jump, but it plays every time I press space. How can I make it play only when my character jumps?

Hey @S1E4AN.TV!

You can try adding a “Do Once” node after jump, with a custom event to reset the “Do Once.”

Then on tick, you’ll check for the velocity to be 0 again. BUT if you ONLY do that, it’ll reset at the arc of the jump. SO we’ll also check for a reset on that! By making sure you descend before the reset of 0 (which would be the landing).

1 Like

Wow! Cool, I’ll wait)

I use a bool variable. It gives me more control over when I ALLOW it to play another sound. If “AllowSound” = true, then set “AllowSound” to false. Then when I have something else trigger the point where the sound is allowed again, I then set “AllowSound” to true. For instance, after the gun has switched to the new gun. It works for everything that is triggered several times and you only want to do it the first time and not every time it’s called.

If you have a movement component, you can get “IsFalling”

1 Like

Thank you sir, I hope your tutorial will also help novice game creators)

I tried, but this option did not suit me, but in any case, maybe it will help other people

I would also like to add a second jump sound here so that they alternate or work in a random sequence.
But when a second “Play Sounds 2D” is added, they play at the same time.

i did it like this
I create “Sound Cue” and i add two sounds file here


Then i just add “Sound Cue” in “Play Sound 2D”