Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
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'? – TheBroodian Jun 15 '12 at 0:20
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. – Patrick Hughes Jun 15 '12 at 0:51
Thank you, this has given me enough to think about to get me working on something. :) Your input is incredibly appreciated. – TheBroodian Jun 15 '12 at 0:53
Don't forget to have fun =) Good luck. – Patrick Hughes Jun 15 '12 at 0:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.