Combo Attack system


Reported by: Eldar Bertsel

November 10, 2023

THE PROBLEM

This week one thing that I worked on was a combo attack system that would add more diversity because having single attack that is the same every time is lame. I had spend a bunch of time trying to find a good way to implement a combo system but after a couple hours of research I figured out that there is no solution on the internet that I like. All of the solutions either have multiple bools to trigger each animation or only work for 2 combo attack. Having multiple bools makes it impossible to change the amount of combo easily because you would need to either add or remove a bool for that attack to trigger and you would have to add or remove the code. Also, what if you have multiple character and they all have different combo attacks, some have 3 attacks, 2 attacks or maybe 4, it is impossible to make it work and be reusable at the same time. 2 combo attacks approach pretty much has the same issues but it had one thing that I could use which is a combo window. It is basically a small amount of time during which you can click a button and something will happen. In my case "something" would be to player the next attack in the combo sequence.

THE SOLUTION 

With all that information I decided to create a combo system that would work for as many attacks as you want and with only one bool in the animator and 2 bools in code, one for the animator bool and one for the combo window bool. The way I implemented it is pretty easy. Every time the player clicks light attack button it sets bool "doCombo" to true. Then It checks whether comboWindow bool is true meaning we are inside the frame of the animation where we can perform a combo. If we are, then, set the animation bool "canDoCombo" to true. This will play the next attack animation. To connect code with animations I used 2 functions and animation events. One function turns window bool on and second function that turns it off.  Second function also sets the bool that tells us that we can perform a combo attack to false. I put those function on the animation using animation events to call them during specific frames of animation. Beside that I also added one more event at the beginning of each animation to turn of comboWindow and doCombo just incase. This way if we are inside a specific window in the animation and we press a light attack button it will play the next attack in the sequence that is created in the animator.   In the animator I just have 4 attack animation, each animation has those same events on them and a transition condition when "canDoCombo" is true.

Get Psyche

Leave a comment

Log in with itch.io to leave a comment.