Ninja Bear Studio Plugins Help

Ranged Attacks

Ranged Attacks are one of the core features of Ninja Combat. They are usually implemented using a combination of Animation Montages, Gameplay Abilities and Projectile Actors, applying specified Damage Effects on collision.

Ranged Weapon Interface

Any object, such as Pawns or Weapons, meant to execute ranged attacks must implement CombatRangedInterface. It defines the source mesh, from which a projectile will be launched.

This interface is designed in a way to support projectiles being launched from different source meshes, based on the socket that is being used.

Function

Description

GetProjectileSourceMesh

Provides the mesh used to launch a projectile from a given socket.

Projectile Interface

Projectiles are the main participants in the ranged combat. They are launched by the Attack Gameplay Ability, or any other ability designed to do so, and carry a pre-generated version of the Gameplay Effect that should be applied when they collide with targets.

Function

Description

GetSpeed

Provides the projectile speed. Can be obtained from a Projectile Movement Component or other means.

PrepareLaunch

Prepares any initial data before the projectile is launched.

Launch

Effectively launches the projectile.

GetImpactEffectClass

Provides a Gameplay Effect applied when this actor collides with a target. Overrides the Gameplay Effect specified in the Ability if one is present.

GetImpactEffectLevel

Level used when instantiating the Damage Gameplay Effect.

SetImpactEffectHandle

Sets the pre-configured Gameplay Effect Handle used by the projectile.

GetDamage

Optionally provides a damage value magnitude set to the Gameplay Effect using combat.data.damage as the data tag.

GetPoiseConsumption

Optionally provides a poise value magnitude set to the Gameplay Effect using combat.data.poise as the data tag.

GetActorsHit

Provides all actors that were hit by this projectile.

GetProjectileImpactStrength

Defines a strength applied when physical reactions are enabled.

HandleImpactCosmetics

Invoked by the Damage System to render cosmetics from a registered impact, via the Gameplay Cue system.

Projectile Actor

The Projectile Actor (NinjaCombatProjectileActor) is an abstract class that can be used as a base for all your projectiles. It fully implements the Projectile Interface, with built-in logic and exposed properties for easy configuration.

This implementation is based on the Projectile Movement Component implementation. It does not assume any specific type of visuals, so you can add a Static Mesh Component, Skeletal Mesh Component, Particle Effects and so on.

Configure a Projectile Actor

  1. Create a new Blueprint based on NinjaCombatProjectileActor.

  2. Add a projectile mesh, it can be a Static or Skeletal Mesh Component, depending on your weapon requirements.

  3. In the Projectile Movement Component, adjust the speed to your liking, but 3000 should be a good starting point.

  4. Configure any cosmetics in their appropriate slots.

The Default Projectile Actor has the following properties that can be used to adjust its behavior.

Property

Description

AimingMode

Determines how the projectile aims for targets when launched.

MaxBounces

Max bounces allowed for the projectile. Zero means " no bouncing ".

TraceChannel

The channel used to trace for target between frames.

ImpactStrength

Strength applied when a physical animation system is in use.

The Aiming Mode supports the following options:

  • Forward: The projectile is launched forward, from its origin socket.

  • Targeting System: The projectile is launched towards a target collecting via a targeting preset, from the Gameplay Targeting System.

  • Location: The projectile is launched towards the location set by SetInitialLocation, which should be called from PrepareLaunch.

Prepare the Weapon for Projectiles

  1. Open the Static or Skeletal Meshes used to represent your ranged weapons.

  2. Place a socket where the projectile is positioned on launch. Make sure that this socket is rotated forward.

    Weapon Sockets

Configure a Ranged Weapon

  1. Open the Rifle Weapon Actor, created in the Weapon Actors page.

  2. Implement the GetProjectileSourceMesh function, returning the Static or Skeletal Mesh that will be used when launching projectiles.

    Weapon Setup
  3. Make sure that your Ranged Weapon has a weapon tag, such as Inventory.Item.Type.Rifle

    Weapon Tags

On top of the functions defined by the Projectile Interface, there are multiple functions marked as BlueprintNativeEvent, so they can be extended in Blueprint or C++. The table below lists some of the most relevant ones.

Function

Description

LaunchForward

Launches the projectile forward, considering the Initial Rotation.

LaunchToTarget

Launches towards the provided target actor.

HandleTargetNotFound

Launches the projectile when no target was found by the targeting preset.

LaunchToLocation

Launches towards the location, most likely set in PrepareLaunch.

GetInitialRotation

Defines the initial rotation, when the projectile is launched forward.

Projectile Requests

Projectile Requests are used to launch projectiles during an attack. While animation triggers the launch event, the projectile is ultimately spawned by the Gameplay Ability.

Configuring a Projectile Launch

  1. Create or open an Animation Montage that represents the ranged attack.

  2. Find the frame where the launch should happen and add a Launch Projectile Animation Notify.

  3. Configure the Animation Notify to launch the projectile from a weapon, retrieved dynamically from the Weapon Manager, using the weapon query to match with the desired weapon (e.g. Inventory.Item.Type.Rifle).

    Weapon Tags

Projectile Request Class

This object is used to transfer launch data between all the framework layers: Animation, Ability, and Task. It contains the logic to spawn a projectile actor, including the option to retrieve it from the Actor Pool.

The Launch Projectile Anim Notify creates an instance of this class which will be used by the Attack Ability to ultimately spawn a projectile actor, when the gameplay event is received.

Projectile Launch and Hit Flow

We can summarize the projectile lifecycle with the following events:

  1. The Ranged Attack Ability is triggered and plays the Animation Montage.

  2. The Animation Montage plays the Launch Projectile Animation Notify.

  3. The Animation Notify sends a Gameplay Event to the current Attack Ability.

  4. The Attack Ability retrieves the Projectile Request from the event payload and spawns the projectile.

  5. On hit, the projectile applies the Gameplay Effect on the target.

Attack Ability

The Attack Ability is responsible for Melee and Ranged attacks. To get started with Ranged Attacks, all you need to do is setting the Default Animation Montage and make sure to assign this Gameplay Ability to your character.

Configuring the Ranged Attack

  1. Create a Gameplay Ability based on CombatAbility_Attack.

  2. In the Ranged Attack category, set the Projectile Class that will be used by this attack.

  3. Configure the Animation Montage previously configured, with the Launch Projectile Animation Notify.

  4. When you are done, your Ranged Attack should be similar to this.

    Ranged Attack

Actor Pooling

Projectiles are a common candidate for Actor Pooling. This reduces the cost of spawning and garbage collecting projectile actors constantly used in the game.

Ninja Combat has an Actor Pool and the default Projectile Actor is also a Poolable Actor. The default spawn logic in the Attack Gameplay Ability will take that into consideration and will try to retrieve an actor from the pool, before spawning a new one in the world.

Check the Actor Pool page for more information about enabling the Actor Pool and registering the projectile actor to it.

Last modified: 20 June 2025