Combos

Heres an interesting topic i was recently thinking of.

      Say I was to make a Hand to Hand combat game what would be the best way to implement a combo system. I though of a couple ways but i fell back to two basically making one long animation with the full combo and each successive button press advances the animation a couple of frames… or to have more control, and so i can reuse certain animations, create multiple moves and string them with an if branch so say i can reuse jab if it was the start of two combos and add effects or speed to the animation.

How would you implement this??

I think you'd probably want some sort of transition motion as well…    I might consider creating animations based on:



"Start Upper Body Movement"

"End Upper Body Movement"



"Start Lower Body Movement"

"End Lower Body Movement"



"Transition Upper To Lower"

"Transition Lower To Upper"



The idea is that your bind pose is this kind of 'half-ready' position where your idle animation (like swaying back and forth) has ended and the stance has intensified.  From here, you can create your left punch, right punch, left kick, right kick, etc.  A combo sequence might end up looking like this:





"Start Upper Body Movement"

"Right Jab"

"Left Jab"

"Transition Upper To Lower"

"Right Kick"

"End Lower Body Movement"



The "end movement" animations would always get you back to a place where the idle/defense animation can pick up again.



As far as how to implement the code my first thought would be to set up your commands for the different moves and then check to see if a new move was entered before the last "action move" (jabs, kicks, etc) ends.  This way, you can just queue up a transition and action move if they do it fast enough.



Example:


  • Player initiates jab

  • Player initiates kick before end of jab

  • Game adds a transition and kick animation to the queue



Everything's done on the fly this way so there's no lag between inputting a zillion key combos and throwing punches and kicks

I have something similar to what sbook proposes,  I have a kickAnimator and punchAnimator( I use the ancient md5 loader, I like the tooling), for now I use a simplistic int counter punch is 1 and kick is 2 and these 1s and 2s are placed in a queue(LinkedList), which is then traversed from the top, removing the the first element when the IAnimationListener returns cycle_ended on the triggered animation. To avoid the queuing of tonnes of commands that will simple play until the queue is empty, I added a time limit between key commands, so that if for example 10 moves are in the queue and the time limit between input commands is met the queue is emptied after the last executed move or there abouts.



u should use the ogreloader though, I had asked for an interface to be incorporated into the animation system, similar to the one I mentioned above, but I dont think its added yet, but I there might be other ways to do similar.