# Lock On and Align an Attack

> For the complete documentation index, see [llms.txt](llms.txt).

Put a marker over a selected opponent, then make the character step toward that opponent during the opening of a melee attack.

Procedure: Acquire and release an opponent

1. Create a Targeting Preset. Add Current Target Selection and enable Select Targets in Area for the initial search. Use a capsule on the combat channel sized to cover both test targets. Follow it with Dead Filter, Facing Filter, and Distance Sort. Place two targets at visibly different distances.

2. On each target add a Scene Component at the desired marker position and give it the component tag `Combat.Component.TargetLockAnchor`. Create a `NinjaCombatMarkerActor` Blueprint with a visible widget and set it as Target Marker Actor Class on the locking character's manager.

3. Grant a `CombatAbility_TargetLock` Blueprint with this preset assigned. Activate it from your lock action. To unlock, send `Combat.Event.Target.Dismissed` to the character. Enable distance tracking and set the distance threshold if leaving range should break lock.

Procedure: Align the moving part of the attack

1. Add `NinjaCombatMotionWarpingComponent` to the attacker and return it from `GetMotionWarpingComponent`. Use a root-motion attack and enable root motion in the animation setup.

2. On the montage, place Track Motion Warp Target across the approach. Assign the same targeting preset so its Current Target Selection task finds the locked opponent. Give it a warp name, such as Combat Warp. Add a Motion Warping notify state over the root motion to adjust. Choose Skew Warp and enter the identical warp target name.

![Motion Warping notify aligned to a named target in the montage](Documentation/cbt_guide_melee_animation_motion_warping.png)

For a custom lock HUD, bind `BindToCombatTargetChangedDelegate` and update it from the new target, including an empty target on release. For a scripted approach, the Combat Motion Warping Interface exposes `SetCombatWarpTarget`, `StopTrackingWarpTarget`, and `ClearCombatWarpTarget`. Use the same warp name throughout.

## Try It in Play

Lock on with both opponents ahead. Check which one receives the marker, then start the attack from slightly off-center and watch the approach. Release lock or walk beyond the configured threshold. The marker should clear. If the marker is correct but the step misses, check the two warp names and the root-motion frames.

