Attack combo setup (logic bricks)

Hey there, its been a while now.
But I’m finally back, though this time not with questions, but with an (hopefully useful) answer!

I figured out how to make a pretty solid combo system using logic bricks that doesn’t require the use of a whole bunch of states and is all glitchy and filled with problems (unlike the ones in tutorials currently available, as far as I’ve seen. Even the python script tutorial has problems).
What this system will use are properties and messengers.
Not only will this allow you to make strings of combos as long as you want (unlike the ones that rely on states, of which there is a limited amount), it doesn’t have the extreme and extensively repetitive hassle of adding a ton of logic bricks in each state for it to work.
So, lets begin!

First the basic set up.
Your character’s mesh should be parented to the bones which animate it.
The character’s bones should in turn be parented to a simple shape which is for the character’s physics (the selected rectangle).
Parented to the physics box is an empty (also selected) which will handle all the key inputs for the combos.

First off, the empty’s logic is as follows:

That’s…quite a bit of logic.
I’ll break it down for you.
Firstly, notice the properties tab. I got one integer named “combo” and a timer named “combo timer” (I know, there’s a third one, but that one isn’t important right now).
The timer will constantly be counting up and will be responsible for timing the combo’s correctly and resetting the “combo” property back to 0.

Next:
[ Keyboard sensor - tap ]---------------[ and ]------------------[ Property - add - combo - 1 ]
[ Property - greater than - combo timer ]________________[ Property - assign - combo timer - 0 ]
(your value)

Both sensors and actuators are connected to the same “and” controller.
The keyboard sensor detects the key press of your choice. What it does is it adds 1 the “combo” property and returns the “combo timer” property back to 0.
The keyboard sensor has the “tap” toggle active. This makes sure the signal gets sent only once to the actuator, regardless if the key is pressed in longer.
The property sensor is there to avoid key spamming. It will only allow the signal of the keyboard be sent if the “combo timer” property is greater than a certain value (something you can assign yourself. The greater the value the longer the time between individual moves will be).

Next:

[ Property - equal - combo - 1 ]------------- [ and ]-------------[ message - (your message) ]

The property sensor will detect the value of the “combo” property. If its equal to 1, the sensor will send a message.
You can add as many property sensors you like to create the combo chain, each of them detecting another value of the property “combo” (1, 2, 3 etc) and sending a message (the message can be anything you like, but I suggest you keep it simple. For example “hit 1” for the first move and “hit 2” for the next and so forth).
The message is for the character’s bones, and they’ll detect the messages as follows if you add these logic bricks to the bones:

[ Message - (your message) ]--------------[ and ]--------------------[ Action - play - start frame: xx end frame: xx ]

The message sensor will detect your message from the empty with the combo logic and play the assigned action/animation.
There are a few things you need to make sure of in the action actuator:
/uploads/default/original/4X/1/5/3/1539ee28809b7f41b73dea9c3ed004cff3d0f52f.PNGstc=1
For one, you need to make sure that the animation is on “play” and not any of the other options (since its not supposed to be a looping animation).
Another thing is to make sure the actuator’s priority is on a lower value than any other animation priority (the lower the number the higher the priority).
And lastly, this is very important, make sure the “continue” box is not ticked. Keeping this active will make the actuator try to continue the animation where it left off. this means that the action will only play right the first time and not at all the next time.

So, back to the empty with the combo logic.
We still need to close the combo loop, because right now if you keep pressing the attack key it will continue to add values to the “combo” property endlessly.

[ Property - equal - combo - 3 ]------------- [ and ]-------------[ message - (your message) ]
___________________________[ or ] [ property - set - combo - 0 ]
[ Property - greater than - combo timer ]
(your value)

On your last combo (in this case the third one) add a property actuator connected with an “or” controller which sets the property “combo” back to 0, closing the loop and starting the combo chain from the start again nest time you press the attack key.
Connected to the same “or” controller, add another property sensor which detects if the property “combo timer” went over a certain value.
In all action games, if you wait too long with executing a combo, the combo will be reset to the start. The property sensor detecting the property “combo timer” will make sure this happens.

And that’s it!
If you’ve followed this tutorial you will have created a combo system for you character!

There’s just one more thing I’d like to add, which isn’t very important to the combo system itself, but might still be nice to know.
As it is currently, you’d still be able to move the character around like normal while executing the combo.
Most action games I know do not allow to move/run normally while executing a combo, but instead the character takes a step forward with each attack.
This is solved easily and is likely the only time you’ll need to use another logic state:

Make sure that you character physics box (the one thing responsible for all your character movement) can detect the combo messages. That, or make your attack key send a message specifically to the physics box.

[ Message - (your message) ]-------------[ and ]-----------------[ state - set state - (your state) ]

The next state is where the actual step movement will happen.

[ Always - tap ]-----------------------------[ or ]-------------------[ motion - character motion - (your speed/direction) ]
[ Message - (your message) ]

The “always” sensor has the “tap” toggle active. This makes sure the signal gets sent only once to the actuator.
The message sensor will detect the same message that changed the state of the physics cube to continue the steps when the attack key gets pressed multiple times.
Also make sure that your “combo timer” property sends a message to the physics box if the timer is above a certain value. This can be easily done by adding a message actuator to your final attack move’s “or” controller.
This will make sure that the logic state of the physics box will return to normal after a delay.

I hope this is helpful to someone.
Cheers!

Attachments




Thanks for sharing this. Will definitely check this out in-depth once time allows. Cheers =)

Thanks a lot! That’s exactly what I need right in this moment!

I made a system in the past that did this with python

its actually where I got the idea for wrectifieds actor controller

you build a list of sensors in a order,
like

[Up,Left,Down,Right]

then each frame, you build a list of the names of all sensors that are positive, this list is piped to the actor, the actor adds the current move, to a list that he keeps
that is the moves and a timer
[[move1,time],[move2,time]] etc

so moves fall off the list over time

i was able to make Ryu’s fireball move from streetfighter (down roll to downforward to forward) press button

any intrest in seeing the system?

after it is setup, you would just setup you can check the moveList[0] values to see if a combo is happening or super move etc,

building a list of moves to check against would not be a bad idea.

Attachments

ComboTronic.blend (507 KB)

Thanks for posting this Tattorack, I’m new to the BGE so this is something I can’t wait to try out. One quick question. Just to be sure I’m attaching the logic bricks to the empty and the empty is a child to the block that controls that also has the skeleton rig as a child right?