Ninja Bear Studio Plugins Help

Casts

The term "Cast" comes from the traditional RPG expression, spellcasting. However, this Gameplay Ability can also be used as a base for other abilities that require complex target selection (friendly or hostile), optional target confirmation and diverse options regarding how to apply gameplay effects to these targets.

Cast Ability

The Cast Ability can be configured in many ways to support different design goals. Below is a property summary, followed by details on supported triggers, targeting options, and commit timings.

Property

Usage

Description

Cast Trigger

Any

Defines when the cast will actually happen. See the Cast Triggers table below.

Targeting

Any

Defines how the ability collects targets. See the Targeting table below.

Commit Time

Any

Defines when the ability commits its cost and cooldown. See the Commit Time table below.

Cast Effect Class

Any

The Gameplay Effect class applied to all acquired targets.

Cast Effect Level

Any

The level used when applying the Gameplay Effect.

Cast Actor Class

Spawn Actor

The Actor to spawn when using Spawn Actor or Wait for Confirmation and Spawn Actor. Must implement CombatCastInterface.

Targeting Preset

Targeting System

Targeting Preset used when using the Targeting System option.

Targeting Actor Class

Confirmation

Actor used to confirm and collect targets (e.g., ability target reticle).

Section When Confirmed

Confirmation

Montage section to play when the target is confirmed.

Section When Cancelled

Confirmation

Montage section to play when the target is cancelled.

Confirmation Type

Confirmation (no Actor)

Confirmation type used by the Gameplay Ability System when confirming targets without a custom actor.

Cast Triggers

Cast Trigger

Description

Ability Activation

The cast is triggered as soon as the ability activates.

Gameplay Event

The cast is triggered when a Gameplay Event is received, typically from a Cast Animation Notify.

Targeting Options

Targeting

Description

Targeting System

Uses a Targeting Preset from the Targeting System to collect targets.

Spawn Actor

Spawns an Actor implementing CombatCastInterface to collect targets (typically using collision).

Wait for Confirmation

Uses the Gameplay Ability System to allow the player to confirm a target or location.

Wait for Confirmation and Spawn Actor

First confirms the target location, then spawns an Actor to collect targets at that location.

Commit Time Options

Commit Time

Description

Ability Activates

Commits cost and cooldown as soon as the ability activates.

Cast Starts

Commits as soon as the cast is triggered.

Targets Acquired

Commits only if at least one target is acquired.

Ability Ends

Commits at the end of the ability, regardless of outcome.

Cast Requests

Similar to the Combat Ability, that uses Melee Scans and Projectile Requests as data transfer objects, the Cast Ability uses Cast Requests for the same purpose.

Cast Requests are usually sent by the Cast Notify and are received by the ability as the payload in the Gameplay Event identified by Combat.Event.Cast.

Configuring a Cast

  1. Create or open an Animation Montage that represents the cast.

  2. Find the frame where the cast should occur and add a Cast Animation Notify.

Cast Request Class

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

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

Executing a Targeting Preset to Apply Damage

Let's begin exploring usage scenarios for the Cast Ability, starting with the most straightforward one: collecting targets using a preset and applying damage. This is usually enough for abilities such as buffs and debuffs.

Configure the Targeting Preset

  1. Create a new Data Asset based on TargetingPreset.

  2. Add a Targeting Task to select actors in an area, using a capsule shape with a radius of 500. Use the CombatObject collision channel.

  3. Add a Filter Task to exclude actors that do not match your base actor class or type.

  4. Add another Filter Task to remove actors that are already dead.

Cast Targeting Preset

Create the Damage Effect

  1. Create a Gameplay Effect extending from GameplayEffect.

  2. Add a Modifier that increases the Pending Damage attribute.

  3. Add CombatExecution_Damage to the list of Executions.

  4. In the Execution section, add a Modifier that multiplies the Base Damage by 2.0, or any value you prefer.

Cast Gameplay Effect

Create the Cast Ability

  1. Create a Gameplay Ability extending from CombatAbility_Cast.

  2. Set the Cast Trigger to Gameplay Event.

  3. Assign the Gameplay Effect you created as the Cast Effect Class.

  4. Set Targeting to Targeting System, and assign the Targeting Preset created earlier.

  5. Assign the Animation Montage that includes the Cast Notify as the Default Animation.

Cast Gameplay Ability

If you execute this ability in-game, it should apply the configured Gameplay Effect to all valid targets around the player, based on the criteria defined in your Targeting Preset.

Spawning a Cast Actor to Apply Damage

The next usage scenario covers spawning a Cast Actor that uses its physical presence in the world to collect targets and apply a Gameplay Effect. This is useful for abilities where damage is applied by a spawned actor, such as a "Black Hole", "Tornado", or similar effect.

Actors used by the Cast Ability must implement the CombatCastInterface. Ninja Combat provides a base implementation, NinjaCombatCastActor, which you can extend to create your own Cast Actors.

Create the Cast Actor

  1. Create an Actor extending from NinjaCombatCastActor.

  2. Add any visuals you like, such as a Static Mesh, Niagara Effects, or Audio Components.

  3. Adjust the size of the built-in Sphere Collision and configure it to act as a Combat Collider.

Cast Actor

Create the Cast Ability

  1. Open the Cast Ability previously created (or a duplicate of it), and set Targeting to Spawn Actor.

  2. Assign your Cast Actor to the Cast Actor Class.

Cast Gameplay Ability

If you execute this ability in-game, it should spawn your Cast Actor and apply the configured Gameplay Effect to all valid targets detected by the actor’s collision settings.

Selecting the Spawn Location for the Cast Actor

Now let’s take the Cast setup one step further by introducing a Gameplay Ability Target Actor.
The Gameplay Ability System uses actors based on GameplayAbilityTargetActor to handle targeting logic.

The result of this targeting process can be either a group of actors or a location, depending on the Targeting Mode set on the Cast Ability.

  • When set to Wait for Confirmation, the Target Actor provides a list of targets.

  • When set to Wait for Confirmation and Spawn Actor, the Target Actor provides a location, which is used to spawn the Cast Actor.

Create the Cast Ability

  1. Open the Cast Ability previously created (or a duplicate of it), and set Targeting to Wait for Confirmation and Spawn Actor.

  2. In the Targeting Actor Class, select the Ability System Targeting Actor you want to use.

  3. Configure your input system to call LocalInputConfirm on the owner's Ability System Component when confirming the target.

Cast Gameplay Ability

If you execute this ability in-game, it will spawn your Targeting Actor according to your configuration.

Once the target location is confirmed, the ability will spawn your Cast Actor and apply the configured Gameplay Effect to all valid targets detected through its collision settings.

Cast Interface

Any actor meant to be used with casting must implement CombatCastInterface. It defines the source responsible for spawning the actor (e.g. the combatant), the Gameplay Effect Handle applied and the main execution function.

Function

Description

GetCastOwner

Provides the actor that "owns" this Cast Actor.

SetCastOwner

Sets the actor that "owns" this Cast Actor. Usually invoked by the Gameplay Ability, when spawning the actor.

SetGameplayEffectHandle

Sets the Gameplay Effect Handle applied to targets.

StartCast

Starts the cast, performing its logic, target collection, etc.

Cast Actor

Cast Actors are commonly used during casting. They are created by the Cast Gameplay Ability (or another ability) and contain a pre-generated Gameplay Effect that is applied to targets they collect—typically via collision.

The base Cast Actor includes the following properties:

Property

Description

Should Ignore Source

If true, automatically ignores the cast source during collision checks.

Try to Align with Floor

If true, attempts to align the actor with the ground surface.

Floor Trace Channel

Trace channel used to detect the ground surface.

Floor Offset

Vertical offset applied after aligning with the floor.

In addition to the required interface functions, the base Cast Actor provides the following helpers:

Function

Description

Get Cast Source

Retrieves the actor responsible for the cast.

Get Weapon

Retrieves a weapon from the source using a Gameplay Tag Query.

Try Align With Floor

Attempts to align with the floor if enabled.

Align With Floor

Executes the trace logic. Can be overridden to customize behavior.

Apply Effect To Target

Applies the configured Gameplay Effect to a specific target.

Cast Actor

The example above illustrates a typical implementation:

  1. Extends the StartCast function and calls the logic from parent.

  2. Sets the Cast Actor’s location to match the owner’s shield, retrieved via GetWeapon.

  3. Binds an event to the Particle System and resets (then activates) the Niagara Component.

  4. Resets and activates the Audio Component.

  5. When the particle effect completes, the actor is deactivated and returned to the pool.

Modifying the Gameplay Effect

Cast Actors are designed to be independent of the owner's Ability System Component. This ensures they can apply Gameplay Effects even if the source ASC is no longer valid at the time of execution.

If you need to modify the Gameplay Effect Spec generated by the Gameplay Ability, you can do so using Set By Caller Magnitudes, Curve Modifiers, or Dynamic Tags.

You can implement the following functions for customization:

  • GetDynamicGameplayTags: Adds dynamic Gameplay Tags to the effect spec as targets are acquired.

  • GetAdditionalSetByCallerMagnitudes: Injects or overrides magnitudes in the spec using Set By Caller data.

If you need deeper customization of the Effect Handle itself, you can override:

  • ApplyGameplayEffectToData: Full control over how the spec is applied to each target, available only in C++.

Actor Pooling

Cast Actors and Targeting Actors and are good candidates for Actor Pooling. This helps reduce the cost of spawning and garbage collecting these actors when they are frequently used in the game.

Both actors are Poolable Actors, ready to be used in conjunction with the Actor Pool provided by Ninja Combat. For more information on enabling the pool and registering your Cast Actor, check the Actor Pool page.

Last modified: 22 April 2025