Stop Player WASD Controls During Death Animation

Whenever the death animation plays, I noticed I can interrupt it with the player controls and I don’t want that.
How do I change it???

There are a few ways. If you aren’t using a behaviour, do a check that your death animation isn’t playing before handling keypresses (so effectively the keypress events are a subevent of the animation != death event).

Another way is to have a boolean variable, say processPlayerInput, and add it as a condition in each of your keypress conditions. The bonus with this is that you could use it to prevent player input when a pause menu is displayed.

If you are using a behaviour to move the player, then you can turn the behaviour off while the death animation is playing, and turn it back on when it’s needed. Though I don’t know how it will affect a player object if it’s platformer character and is on a platform. I guess it’ll be a case of try it and see.

1 Like

Base all player movement on a global variable or scene variable i.e.
Global g_player_can_move = 1

Place a condition
if g_player_can_move =1
Do all your events that move the player

When your player dies set g_player_can_move = 0
So if the variable is 1 all movements will be available for the player if is 0 no movement will be available.
In my case I have some other variables because my player can talk so if he is talking I don’t want it to move the player.
Hope this helps.


Thanks! I’ll try it!

I had this same problem in my game, and at first I did like the suggestions above and added logic to disable input and removed the platformer behavior… but I found that the platformer behavior was retaining some momentum if you died while jumping… and I couldn’t get rid of it.
So I ended up deleting the platformer object when the player dies, then playing the death animation, and then creating a new platformer object when the player respawns.