Create Melee Attacks
This how-to will show you how to create your first Attacks, using a Melee Weapon.
Add the Melee Scan Sockets
Open the Static Mesh for the Sword and add three sockets along the blade.
Make sure to prefix your sockets with
sScan
. The prefix will be used shortly.
Create the Animation Montage for a light attack
Create an Animation Montage based on an appropriate Animation Sequence that represents the Light Attack.
In the Animation Montage, add the Melee Scan Notify State along the frames where the scan should happen.
In the Notify State Details, set the Source to
Weapon
and your Scan Channel toWeapon
.Configure the Weapon query, so it will obtain the sword from the Weapon Manager.
Create the Animation Montage for a heavy attack
Repeat the same steps from the previous procedure, this time for a heavy attack.
Create the Light Attack Ability
Create a new Gameplay Ability for your Light Attack, using the
CombatAbility_Attack
as the base.In the Details Tab, enable the Is Melee Attack and disable Is Ranged Attack flags.
Set the first Animation Montage for the Light Attack to the Default Animation Montage.
Disable the Motion Warping functionality.
Add
Ability.Attack.Primary
to the Ability Tags, so it can be used for the activation.Add
Ability.Attack.Secondary
to the list of Block Abilities with Tag, to ensure your attacks won't interrupt each other.When you are done, your Light Attack Ability should be similar to the following image.
Create the Heavy Attack Ability
Create a new Gameplay Ability for your Heavy Attack, using the
CombatAbility_Attack
as the base.In the Details Tab, enable the Is Melee Attack and disable Is Ranged Attack flags.
Set the first Animation Montage for the Heavy Attack to the Default Animation Montage.
Disable the Motion Warping functionality.
Add
Ability.Attack.Secondary
to the Ability Tags, so it can be used for the activation.Add
Ability.Attack.Primary
to the list of Block Abilities with Tag, to ensure your attacks won't interrupt each other.When you are done, your Heavy Attack Ability should be similar to the following image.
Add your Abilities to your character
Create an Ability Bundle for the player and add the new abilities to it.
Add the Ability Bundle to the Ability System in the Player State.
Configure your Player Inputs
Create an Input Action for the Light Attack. Add a Pressed trigger. Map this Input Action to your Input Mapping Context, assigning the Left Mouse Button as the key.
Create an Input Action for the Heavy Attack. Add a Pressed trigger. Map this Input Action to your Input Mapping Context, assigning the Right Mouse Button as the key.
Add two Input Handlers to your Input Setup Data Asset, using the Activate Ability by Tags as the base.
Set the correct Input Actions for each attack, and the correct Ability Tags defined earlier:
Ability.Attack.Primary
andAbility.Attack.Secondary
.When you are done, your Input Setup Data Asset should be similar to the following image.
Execute your melee attacks
Click the Play button.
Press the buttons assigned to your attacks, Left and Right Mouse buttons. Your attacks should execute.
Enable the Attack Debug
Open your Attack Abilities and check Enable Debug property.
Click the Play button.
Press the buttons assigned to your attacks, Left and Right Mouse buttons, you should see the melee traces. When you are done, uncheck the Enable Debug property from the Attack Abilities.