Ninja Bear Studio Plugins Help

Create Melee Attacks

With the melee weapons configured, the next step is to create a primary and a secondary attack using the Attack Ability, add these abilities to the player character using Ninja GAS and configure their inputs using Ninja Input.

Add sockets for Melee Scans

  1. Open the Static Mesh for the sword and add three sockets along the blade.

    Make sure to prefix your sockets with sScan, this prefix will be used soon.

    Sword Sockets
  2. Open the Static Mesh for the shield and add one socket at the center.

    Again, make sure to prefix your sockets with sScan.

    Shield Sockets

Configure the primary attack animation

  1. Create an Animation Montage from an appropriate Animation Sequence that represents the primary attack.

  2. In the Animation Montage, add the Melee Scan Notify State along the frames where the scan should happen.

  3. In the Melee Scan Notify State Details:

    • Set the Source to Weapon and your Scan Channel to Weapon.

    • Leave the Scan Socket Prefix value unchanged, since it matches the names used in the sword mesh sockets.

    • Leave the Scan Mode set to Line Trace.

    Primary Attack Animation
  4. Configure the Weapon query, so it will obtain the sword from the Weapon Manager.

    Sword Melee Scan Notify Query

Configure the secondary attack animation

  1. Create an Animation Montage from an appropriate Animation Sequence that represents the secondary attack.

  2. In the Animation Montage, add the Melee Scan Notify State along the frames where the scan should happen.

  3. In the Melee Scan Notify State Details:

    • Set the Source to Weapon and your Scan Channel to Weapon.

    • Leave the Scan Socket Prefix value unchanged, since it matches the name used in the shield mesh socket.

    • Set the Scan Mode set to Box Sweep and set dimensions that roughly match the shield's dimensions.

    Secondary Attack Animation
  4. Configure the Weapon query, so it will obtain the shield from the Weapon Manager.

    Shield Melee Scan Notify Query

Configure the primary attack ability

  1. Create a new Gameplay Ability for your primary attack, using CombatAbility_Attack as the base class.

  2. Set the Animation Montage for the primary attack in the Default Animation Montage.

  3. Disable Motion Warping.

  4. Enable debugging.

  5. Add Ability.Attack.Primary to the Ability Tags, so it can be used for the activation.

  6. Add Ability.Attack.Secondary to the list of Block Abilities with Tag, to ensure your attacks won't interrupt each other.

Primary Attack Ability

Configure a damage Gameplay Effect

  1. Create a new Gameplay Effect using CombatEffect_MeleeHit as the base class. It will be used by the secondary attack.

  2. Add Combat.Effect.Damage.Knockback to the list of Gameplay Tags Added to the Effect.

  3. In the Execution list, add a Calculation Modifier using Combat.Data.Damage.Multiplier and set a Scalable Float with a Magnitude of 1.5.

Knockback Gameplay Effect

Configure a cost Gameplay Effect

  1. Create a new Gameplay Effect using GameplayEffect as the base class. It will be used for by secondary attack.

  2. Add the Additional Effects Gameplay Effect Component and include Cancel Stamina Regeneration in the On Application Gameplay Effects list.

  3. Add a Modifier to reduce stamina by 5.

Cost Gameplay Effect

Configure the secondary attack ability

  1. Create a new Gameplay Ability for your secondary attack, using CombatAbility_Attack as the base class.

  2. Set the new Damage Gameplay Effect, configured on the previous step, as the Melee Damage Effect Class.

  3. Set the Animation Montage for the secondary attack in the Default Animation Montage.

  4. Disable Motion Warping.

  5. Enable debugging.

  6. Set the new Cost Gameplay Effect, configured on the previous step, as the Cost Effect Class.

  7. Add Ability.Attack.Secondary to the Ability Tags, so it can be used for the activation.

  8. Add Ability.Attack.Primary to the list of Block Abilities with Tag, to ensure your attacks won't interrupt each other.

Secondary Attack Ability

Add abilities to the Player

  • Open the Ability Data Asset created for the Player, and add the new abilities.

    Ability Bundle Ability

Configure Player Inputs

  1. Create an Input Action for the Primary Attack. Add a Pressed trigger. Map this Input Action to your Input Mapping Context, assigning the Left Mouse Button as the key. If you have a Gamepad, also map it to the Face Button Left.

  2. Create an Input Action for the Secondary Attack. Add a Pressed trigger. Map this Input Action to your Input Mapping Context, assigning the Right Mouse Button as the key. If you have a Gamepad, also map it to the Face Button Top.

  3. Add two Input Handlers to your Input Setup Data Asset, using the Activate Ability by Tags as the base.

  4. Set the correct Input Actions for each attack, and the correct Ability Tags defined earlier: Ability.Attack.Primary and Ability.Attack.Secondary.

  5. When you are done, your Input Setup Data Asset should be similar to the following image.

    Melee Attack Inputs

Test everything

  1. Click the Play button and execute your primary and secondary attacks, pressing the appropriate buttons.

  2. Both your attacks should execute correctly, and you should see scan lines for the debug.

    Attacks
Last modified: 25 October 2024