Help! 3 state one button controller

I’m trying to build a single button 3 state controller. the three states are:
Hover (if the button is held for longer than 0.25 seconds)
Flap (if button is tapped)
Dive (if no button is pressed for 0.5 seconds, Default state)

I have made a controller that triggers in the correct way but each instance of Hover, Flap and Dive only executes once. so I need to feed them into a while loops.
the problem is I don’t know how to create a boolean that is true only when the other 2 are false.
basically, I want in pseudo-code is:
While (button is held)
Hover = true;
Flap = false;
Dive = false;
While (button is tapped)
Hover = false;
Flap = true;
Dive = false;
While (button is released) default
Hover = false;
Flap = false;
Dive = true;

So that can get continuous input/execution out no matter what state the player is in all using only one button.

Have you considered creating an ENUM combined with a switch in the actors tick?

Also… with Enums you only need one bool:

  • On Pressed start timer and set Hover = true, on Releases set to false.
  • When timer runs out:
    if (Hover)
    // Enum = Hover
    // Enum = Flap
  • If timer is runing and there was a second click, then Enum = Dive and cancel timer because it does not need to check for Hover, it will already be false because it’s set to false on release…


1 Like

@pezzott1 Thank you that is really helpful.
Can I ask, how did you make that image where you can see the flow of the blueprint animated?
it looks super useful to be able to see a live animation of the activations like that.

And it is free:

1 Like

Thanks, I was actually talking about the blueprint debug mode but I managed to find it myself.
cheers for all the help.

Oh, lol. Ok.