How do I script a Combo/Attack Chaining system?
I am working on a game that uses 3 buttons for melee attacks (i.e low, middle, and high attacks). I want to transition from one attack animation to the next if I'm already attacking and I press another one of the attack buttons. I am hoping to find an efficient way to "chain" these attacks so I can later use it to implement final combo attacks as well. Any recommendations would be greatly appreciated. Thanks!
Answer by Hanoble · Nov 18, 2016 at 11:15 PM
There are several ways you could do this, but I recently did something like this using Mecanim and sub-states. Essentially I had an initial state where the attacks started from, then depending on the type of attack I moved into sub-states which had their own logic to handle more attack sequences and sub-states. This was nice because I was able to eventually create dozens of different blends and easily add/remove new ones.
This could also be done entirely within script by simply setting timing windows and ensuring those are still within the right timings and blending animations together. I would think regardless Mecanim is your friend here, as it makes blending a much more visual and easy to setup process.
First of all thank you for the response. I am definitely using mecanim to manage these states. When you refer to an initial state where attacks start from what kind of state would that be? I guess my biggest issue is handling the conditions to transfer from one attack or another or to idle. I can see how sub states would be useful but how would you enter that that initial state and then transition to each sub state. If you could provide even a basic example I think I would understand because I have a feeling I am making things more complicated than they need to be with the way I have things currently. Any further explanation would be helpful. Again, thank you.