Target Lock
Last modified: 27 April 2025The Target Lock system allows players or AI to lock onto enemies for focused movement and attacks.
Locking is visualized through a Marker Actor, which attaches to the target and can be fully customized.
The Target Lock Ability manages acquisition, switching, and disengaging from targets based on targeting presets.
Gameplay Effects and Events can be used to track or react to the lock state in other systems.
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.
note
Target Awareness
The Marker Actor is always aware of its current locked-on target. You can retrieve it at any time via the
GetCurrentTarget
function.
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 |
---|---|
| Finds the anchor point for the target. By default, selects a Scene Component with the appropriate Gameplay Tag. Can be overridden for advanced setups. |
| Handles the attachment logic when locking onto a target. |
| Handles the detachment logic when unlocking or switching targets. |
| Hook for custom logic when a new target is locked. |
| 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.
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 |
---|---|
| If true, automatically rotates the Controller to face the locked target. |
| If true, locks the pitch during lock-on. If false, player input can still modify it. |
| If true, locks the yaw during lock-on. If false, player input can still modify it. |
| 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. |
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.