Create a Combo
The Combo System is used to trigger attack sequences that can even branch out depending on different inputs. In this guide you will learn more about it and how to mix Attack and Cast abilities in a combo.
Create a basic Combo
In this first part of the Combo guide, the default Attack Ability created before will be converted into a combo. This will give you an overview of the combo system, its configuration and main objects.
Configure the Combo Window
Open the Animation Montage used for the Primary Attack.
Add the Combo Window notify state, covering the frames in the animation that will allow the combo to advance.
Configure additional attack animations
Create Animation Montages for all other attacks that will be used in the combo.
Add the Combo Window notify state to all these animations.
Create additional attack abilities
As done before, configure all your attack abilities using the new animations.
Configure the Ability Tags for the attack abilities, following a cohesive pattern, such as:
Ability.Attack.Combo.Primary.A
,Ability.Attack.Combo.Primary.B
, or something similar.Remove unnecessary ability tags from the original Attack Ability, since it won't be activated directly from input anymore.
Configure the State Tree
Create a new State Tree, using the CombatComboComponentSchema.
If you are using Unreal Engine 5.3, add the Combo Component evaluator to the tree and bind the Actor input parameter to the one available in the state tree context.
Add the Combo State evaluator and bind the Combo Manager input parameter to the one exposed yb the Combo Component evaluator or from the context.
Create a new child state from the root, and set it as a state and configure the Selection Behavior to Try Select Children in Order. Name it Primary Attacks.
Create a new child state in the group and name it Primary Attack 01, or any other meaningful name that you prefer. Create all primary attack states for your combo in the same way.
Add an Integer Compare check to the Entry Conditions list. Set the left side to the Combo Count from the Combo State evaluator and the right value to 0, which is the very first possible combo count.
Add an Activate Combo Ability task to the Task list. Set the activation tag to
Ability.Attack.A
, as it was set in the Ability Activation Tags. Configure the Task to increment the Combo Count.Add an Event Transition to the list of Transitions, based on the
Combat.Event.Combo.Attack.Primary
tag. Set the transition to go to Attack 02.Add a Finished Transition to the list of Transitions, Set this transition to complete the State Tree.
Repeat steps 6 to 9 for each other attack, ensuring that the Entry Conditions are updated correctly and the Event Transitions move to the correct next step. The last attack only has the "Finished" transition.
Create the combo ability
Create a new Gameplay Ability, using
CombatAbility_Combo
as the base.Set the state tree configured in the previous step.
Add all abilities used by the combo to the list of abilities.
Configure the Ability Tags, adding
Ability.Combo
, so it can be used for activation.Configure the Blocked Ability Tags, adding
Ability.Attack.Secondary
.
Update the Ability Setup
Remove previous attacks, that are now part of the combo, and were added to the Ability Setup.
Add the combo attack do the ability setup.
Configure combo inputs
Adjust your Primary Attack Input Handler, updating the Activation Tags for the Combo Ability.
Add a new Input Handler to your list of Handlers, using the GAS: Send Gameplay Event.
Set the Primary Attack Input Action and
Combat.Event.Combo.Attack.Primary
tag as the event.
Add the Combo Manager
Open your Character Blueprint and add a Combo Manager.
Implement the Get Combo Manager function from the Combat System interface, returning the new component.
Test everything
Press play and then press your attack button.
In the appropriate combo window, continue pressing the attack and the next attacks should follow.
Cast Ability and Combo Branching
In this second part of the Combo guide, a new Cast Ability will be created to show different kinds of abilities being added to the combo. Then we can use it to branch between primary and heavy attacks.
Create the damage effect for the Heavy Attack
Create a Gameplay Effect based on
CombatEffect_MeleeHit
.Add a Calculation Modifier to the list of Executions.
Set
Combat.Data.Damage.Multiplier
as the Backing Data and a higher magnitude. In this example, we are using2.0
.
Create the damage effect for the Cast Attack
Create a Gameplay Effect based on
CombatEffect_MeleeHit
.Add a Calculation Modifier to the list of Executions.
Set
Combat.Data.Damage.Multiplier
as the Backing Data and a higher magnitude. In this example, we are using5.0
.
Create the additional attack ability
Following the same steps as before, create a new attack that will be used as a Heavy Attack.
Set the Melee Damage Effect to the one created above, for the Heavy Attack.
Configure the cast attack animation
We also need an Animation Montage for a Cast Attack, where the character will perform an explosive attack.
At the appropriate frame, we'll add the Cast Animation Notify, which is used by the Cast Ability to spawn the Cast Actor.
Create a Cast Actor
Create a new Blueprint based on
NinjaCombatCastActor
. This actor will be spawned by the Cast Ability.Set the original Cast Sphere radius to
200
. This is the area of the effect, where targets will be collected.Set the Time To Live Outside Pool property to
5.0
. This will be used later on when we configure the Actor Pool component.Add a Niagara Particle System Component, used to represent the effect. Set the desired effect asset.
Add an Audio Component, to play the effect sound. Set the desired sound asset.
Create a function called
SetLocationFromShieldLocation
. It will be used to place this Cast Actor where the shield currently is.In the Event Graph, implement the
StartCast
event, defined by the base class. The goal is to adjust the location using the function from the previous step, track when the VFX is finished so we can eventually return the actor to the pool, and activate all systems.
Create a Cast Ability
Update the Combo Ability
Add the new heavy abilities - Attack and Cast - to the Combo Ability, so they are automatically added along with the Combo Ability itself.
Update the State Tree
Following the same steps as before, add the Heavy Attack state and appropriate specific states to the State Tree.
Configure combo inputs
Test everything
Press play and start your combo.
After two light attacks, press the secondary attack button. The combo will branch to the first heavy attack.
Start your combo again and after three light attacks, press the secondary button. The combo will branch to the cast attack.