I'm developing a 2D platformer with action-fighter elements. Currently things are working relatively smoothly but I'm having difficulty sorting something out. For the time, keeping my character's states and actions separated and preventing them from stepping on each others' toes is working out well and properly, but I would like to add a feature to my character to get him to behave a little bit more fluidly for the player.

At the moment, he has numerous attacks and abilities that he can execute, all of them being executed with button presses. Here lies the problem: Being as everything is executed through button presses, while an action is in progress I flag the game to disregard further button presses until the action has completed. Therefore, consecutive actions cannot be performed until after the previous action has completed entirely. In runtime this behavior feels very icky, and very ungamelike.

In games that rest most memorably at the forefront of my mind the player is able to execute button commands during the process of actions, and at the end of the current action, the following action is executed (seems like some sort of a queue system or something)

Can anybody offer any guidance with this?


1 Answer 1


Always store the most recent button press, always let a new button press replace the currently stored one. You don't want more than one otherwise your game will feel squishy and unresponsive instead of icky.

The default action of "Idle" always wants to transition, acting on any stored button press immediately. Other actions like "Monkey Steals the Peach" might wait until they're almost done and then check for button presses before forcing a transition to "Idle."

The trick is to always accept a keyboard input and store it for later use. Once an input has been taken from this storage, set the storage to Idle. In this way if the player does not press any buttons he automatically goes to idle.

The second trick is to let all actions check for a stored input a short time before their animations are over and reverting to idle, this is where your smooth feel comes from.

  • \$\begingroup\$ Here's another question just to make things interesting. I have an input sequence manager that stores input in such a manner. However, I use this manager separately to execute 'special abilities' (fireballs and such). 'Normal attacks' (punches, kicks, uppercuts) are handled on the spot as my Update method polls the gamepad for its state, and executes any matching button combinations (thus creating the previously described issue). Would it seem feasible for me to use two input sequence managers, and segregate them, one for 'normal attacks', and one for 'special attacks'? \$\endgroup\$ Commented Jun 15, 2012 at 0:20
  • \$\begingroup\$ So a special ability is triggered by a sequence of inputs? Try this: [input manager with storage] -> [actions pulling from storage ] -> [queue of recent accepted actions]. I wouldn't double up on two systems reading from the same input (the keyboard, joypad, etc). With this version you only trigger special attacks from accepted inputs, stopping players from random button mashing so much. OR if you really do want extra buttons pressed between actions then get the input and split it to two handlers, one with the storage and the other queued like you say. \$\endgroup\$ Commented Jun 15, 2012 at 0:51
  • \$\begingroup\$ Thank you, this has given me enough to think about to get me working on something. :) Your input is incredibly appreciated. \$\endgroup\$ Commented Jun 15, 2012 at 0:53
  • \$\begingroup\$ Don't forget to have fun =) Good luck. \$\endgroup\$ Commented Jun 15, 2012 at 0:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .