Ninja Bear Studio Plugins Help

Target Lock

Certain games allow players to lock onto a specific target, helping them focus their attacks regardless of camera movement or other nearby enemies.

A locked target should also be considered by other systems, such as Motion Warping, to ensure that attacks prioritize the locked target, and Movement, since locking onto a target commonly shifts the character into strafing movement.

The Target Lock functionality is implemented through a dedicated Gameplay Ability, which uses the Gameplay Targeting System and a dedicated Marker Actor to visually represent the current locked-on target.

Marker Actor

The Marker Actor is the first participant in the Target Lock system. It visually represents which target is currently locked on by the player, typically using a widget such as a dot, an arrow, or other visual markers.

The Marker Actor is automatically attached to the current target’s Scene Component tagged with Combat.Component.TargetLockAnchor. This behavior, along with others, can be customized in Blueprint or C++ child classes.

Function

Description

FindAttachAnchor

Finds the anchor point for the target. By default, selects a Scene Component with the appropriate Gameplay Tag. Can be overridden for advanced setups.

AttachToTarget

Handles the attachment logic when locking onto a target.

DetachFromTarget

Handles the detachment logic when unlocking or switching targets.

HandleTargetSet

Hook for custom logic when a new target is locked.

HandleTargetCleared

Hook for custom logic when a target is cleared.

The base actor extends NinjaCombatMarkerActor, which provides a built-in Widget Component and is fully compatible with the Actor Pool provided by Ninja Combat.

Creating a Marker Actor

  1. Create a new Gameplay Widget to represent the marker (e.g., a simple dot or arrow).

  2. In your Content Browser, create a new Actor based on NinjaCombatMarkerActor.

    Marker Widget
  3. Assign the created Widget to the Target Lock Widget Component of your new actor.

    Marker Actor

Target Manager Component

Targets are managed and replicated by a Target Manager Component.
By default, the Combat Manager Component fulfills this role, but any Actor Component implementing CombatTargetManagerInterface can be used.

The Target Manager is responsible for:

  • Instantiating the Marker Actor, based on a predefined class.

  • Storing, replicating, and broadcasting the current target when it is set or cleared.

Controller Rotation

The default Target Manager (provided by the Combat Manager Component) also offers optional controller rotation toward the locked target.
This improves gameplay by keeping the character and camera naturally aligned during lock-on.

The following properties control this behavior:

Property

Description

bRotateControllerToTarget

If true, automatically rotates the Controller to face the locked target.

bLockControllerPitch

If true, locks the pitch during lock-on. If false, player input can still modify it.

bLockControllerYaw

If true, locks the yaw during lock-on. If false, player input can still modify it.

RotationInterpSpeed

Determines the interpolation speed when rotating toward the locked target.

Target Lock Ability

The Target Lock Ability is assigned to any character intended to lock onto targets. Once activated, it collects the best available target using a Targeting Preset and synchronizes it with the Target Manager Component.

Property

Description

Targeting Preset

Targeting Preset used to find an eligible target.

Next Targeting Preset

Optional alternate preset used when selecting a new target after one is dismissed.

Move to New Targets

If true, automatically searches for a new target when the current one becomes unavailable.

Perform Async Targeting

If true, collects targets asynchronously using the Gameplay Targeting System.

Distance Threshold

Optional distance limit — exceeding it deselects the current target.

Target Lock Effect Class

Gameplay Effect applied to the target when a lock is established.

Source Lock Effect Class

Gameplay Effect applied to the source (locker) when a lock is established.

Configuring the Target Lock Ability

  1. Create a new Targeting Preset that will be used to find eligible targets. You can configure filters and selection criteria, remembering that tasks are executed in order.

    Target Lock Preset
  2. Create a new Gameplay Ability based on CombatAbility_TargetLock. Set your Targeting Preset in the ability's properties.

    Target Lock Ability

Gameplay Effects

The Target Lock Ability is pre-configured to apply Gameplay Effects to both the source and the target.
By default, these effects simply assign Gameplay Tags that can be tracked by other systems, but you can extend them to include additional logic or modifiers as needed.

Gameplay Events

You can activate or deactivate the Target Lock Ability either manually (by class or tag) or automatically via Gameplay Events:

  • To activate the ability using a Gameplay Event, send Combat.Event.Target.Acquired, providing the new target actor as the payload's first optional actor.

  • To deactivate the ability, send Combat.Event.Target.Dismissed.

Once the Target Lock Ability is configured, players (or AI) will be able to seamlessly acquire, track, and disengage targets during combat.

Integrated Systems

A common requirement for a Target Lock system is to have its owner strafing whenever they are locked onto a target.
Two relevant systems are automatically integrated with Target Lock:

  • Character Movement Manager: The default Combat Character Movement Manager component can automatically toggle strafing when its owner has a locked target.

  • Combat Animation Instance: The base Combat Animation Instance automatically updates its strafing property based on whether the owner currently has a locked target.

Last modified: 27 April 2025