Skip to content

Combat Targets

Targets are collected and transfered across the system for different purposes. Here are a few scenarios:

  1. During Melee Attacks, when Motion Warping is used or during the Melee Scan.
  2. When Projectiles are launched and must hit a specific target.
  3. Area of Effect abilities that will collect multiple targets.
  4. Locking on and navigating targets.

Even though some abilities will provide simpler alternatives to collecting targets, usually the most common way to do so is using the Gameplay Targeting System.

Targeting Presets

Targeting Presets (UTargetingPreset) are the Data Asset used by the Targeting System to collect, filter and sort targets. They are declarative ways to configure scans, which is very designer-friendly.

Let's check an example of how to configure this preset.

Combat Targeting Preset

  1. Target Selection: This determines how targets will be selected. It uses shapes to delineate an area of effect and then performs a scan on the configured channel/profile to collect actors.

  2. Filter by Class: This filter includes or removes certain class types from the initial target selection. You can use multiple filters to fine-tune your resulting group of actors.

  3. Filter by Alive/Dead Status: This filter is provided by the Combat Framework and will filter out actors that are dead, as per the IsDead function from the UNinjaCombatManagerComponent. You can optionally invert this test, to exclude alive targets.

  4. Filter by Facing Angle: This filter is provided by the Combat Framework and will filter out actors that are not facing an angle that is lesser or equal than the maximum angle provided.

  5. Sort by Distance: You can prioritize targets by sorting them by a criteria. In this case, they are sorted by their distance from the owner. Alternativelly, you can determine if this sorting should be ascending or descending.

Make sure to check available tasks

Make sure to familiarize yourself with the collection/filtering/sorting tasks available, both in the core Gameplay Targeting System and in the Ninja Combat plugin. Also, check the official documentation to understand how to debug the target acquisition as that may prove very useful.

Target Lock Ability

This Gameplay Ability is the System's main way to collect targets from Player Input. You can extend from UCombatAbility_TargetLock and configure your Blueprint as needed.

Target Lock Ability

Property Description
TargetingPreset The Targeting preset used to gather filter and sort targets. The first result is selected.
PerformAsyncTargeting Determines if targeting should happen asynchronouusly.
DistanceThreshold Distance limit, from the selected target, before the avatar disengages.
TargetLockEffectClass A Gameplay Effect that informs that the avatar is locked to a target.

Target Manager Component

This component receives the selected target as well and replicates it to all relevant clients. When the replication happens, the new target is broadcasted to all subscribers to the component's CombatTargetChanged Multicast Delegate. You can bind to this delegate via Blueprints or C++ (via the appropriate ICombatTargetManagerInterface).

Leveraging the Target Broadcast

Binding to this event would be a good way to react to new targets in your Animation or Locomotion system, in case you want to toggle strafing or change walking speed, which are common requirements for adventure games.

Forcing Targets

You may want to force targets in your game. Maybe forcing a player to be already focused on something or an AI agent to have a target. You can do that by activating the ability via a Gameplay Event Trigger (preferred) or use the Component's function to set a new target.