[SOLVED] Prevent Key being still pressed (Finite State Machine)

I’m currently trying to prevent the player from keeping a key pressed, but i can’t figure it out,

I tried to add an event where the key is still pressed, the animation is the jumping one but with a “Player is on floor” But it make the animation not working at all, so I delete theses lines.

Maybe someone can help me preventing the key being pressed ?

( So : Player jump = Do an animation BUT when Player Jump + Keep Space Down = Animation of jump on the floor)

If you need more content, ask me :slight_smile:

Anyone knows how can I do it ? ^^

Are you talking about preventing multiple jumps if the space key is held?

Oh I don’t have this variable; imma check, thanks for your answer

Ok so it work’s for What i wasnt figuring out but not for what i want to do ^^
In fact, when my player jump, he do an animation, when i press and release Space, everythings works fine, the player run to either his idle or running state. The problem is, when i hold down space key, the spin jump animation continue to play even if the player is on ground (the jump animation is set to not be possible (normally) on the floor

You have a lot of scenarios. It’s tough for me to tell. Sometimes it’s just a matter of arranging them so the highest priority one is done last or making sure they don’t conflict with one event changing something and another one undoing it. There’s just too much for me to decode. I’m sure someone else can help.

1 Like

I’m using a finite state machine, so there is (almost) no chance of conflict since everything works, it’s just the key that is being held down that do something wrong, because I want press input and not hold input for the jump

I like to use a lot of subevents. It helps me understand the process and reduces events. This is just my personal style. You be you. But this helps me greatly. You can sort it in any way you want although I would keep the key event at the top. In my example, it only checks if space is pressed once instead of several times and it doesn’t check anything else if the space key isn’t pressed.

1 Like

It’s a little too much for me to process. You might need to add a variable to track when space is released or pressed or what its previous state in the last frame was. I wish you the best.

1 Like

Ok thanks i’m gonna check for the variable, but if you want my advice, you should try to use a finite state machine, less code, more organized and easy to use, I only struggle with that holding key x)

Thanks. We all have different styles. If it works for you, great. I like more structure. It’s easier for me to process. Be well.

1 Like