Cancel action before time runs out by pressing the same button.

Hello!

I am trying to recreate an old Gameboy game in UE5, namely “Gargoyle’s Quest”. My issue is this: If we press the jump button a second time while the character is still in the air, then he can fly on the same altitude (same z-axis coordinates) for a couple of seconds. After that, he falls down to the ground again. Like shown in the gif below.
firebrand

I have managed to replicate these mechanics using blueprints (I’m a noob so it wasn’t easy), but there is yet another thing that I need to make him do: while he’s flying, pressing the jump button a third time should cancel the flight and make him fall down. So he’ll either fall down if the timer (delay) runs out, or if we press the jump button. I can’t even begin to think how to make this happen. The blueprint (see below) is rather complicated already, so I don’t know if I need to figure out a different solution from scratch or if there is some solution that I am not aware of. Here is my blueprint:

I am guessing that I need to put something before the Delay node? I’m really at a loss… Any help from more experienced developers would be greatly appreciated! Thank you very much in advance!

My sugestion:

  1. He’s on the ground: Jump
  2. He’s jumping: keep it’s altitude AND create a Set Timer by Function ( for example ).
    Create a function “Falls Down” that use the code for the character falls down.
  3. If he’s jumping AND keeping the altitude: you can call “Falls Down” and clear the Timer you created. If the player doesn’t press the jump button the Timer will call you function and the character will falls down anyway.
1 Like

Thank you very much for your reply! What you say makes perfect sense, I just lack the knowledge (still) to understand all of it. I will do some reading based on your suggestions and hopefully I’ll be able to figure it out eventually :slight_smile:

This may help:

I use Timer with C++, so I don’t have examples with Blueprint.

1 Like

Thank you so much, this definitely helped! I have now cleaned up my blueprint and it looks much better. This is the new Input Action blueprint:

And this is the Falls Down function that I created based on your advice:

The issue now is that I have no idea how to tell it to call the Falls Down function (and clear the timer) when Jump is pressed again… Any ideas on that would be greatly appreciated. Thanks again!

Ι finally figured it out! I had already created a separate input action called “Fly” back when I hadn’t figured out how to set this all up on a single input action (jump). It is practically the same as the “jump” action (digital (bool) type with Space Bar set up as the key value in the IMC. So I just used that one to clear the timer and call the “Falls Down” function :slight_smile:

So in case someone else has the same issue, here is my completed blueprint (so far):

And, again, this is the Falls Down function.

I’m marking this as the solution, but I wouldn’t have done it without your help, @SolidSk, so thanks a bunch!

1 Like

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