Configure the Target Lock
The Target Lock Ability helps with camera focus, precision and add visual indicators to a target. This system uses Unreal Engine's Gameplay Targeting System to collect targets.
Create a Targeting Preset
Create a new Targeting Preset. It will be used for the target selection.
Add the Camera Selection Task. You can use its default values or adjust them as you like.
Add the AOE Selection Task. Use a Sphere shape, add Pawn and World Dynamic as Collision Object Types, set it to ignore the source actor and instigator, and a radius of 1600.
Add the Actor Class Filter Task. Set your base Character Class as the Required Actor Class Filter, or adjust these filters to match your character hierarchy.
Add the Facing Filter Task. Set the maximum angle to 60, or any other value that makes sense to you.
Add the Dead Filter Task.
Add the Sort By Distance Filter Task.

Configure the Target Lock Ability
Create a new Gameplay Ability using
CombatAbility_TargetLock
as the base class.Set the Targeting Preset that was created in the step above.
Disable Move to New Targets for now, but feel free to explore this if you'd like.
Set the Distance Threshold to 1600, or any other value that makes sense to you. This will disengage from the target, if the distance from the avatar exceeds this value.
Add this Gameplay Ability to the list of Default Abilities added to the player.

Configure the enemy anchor
In your Base Character (or Base Enemy Blueprint), add a new Scene Component under the main Character Mesh.
Set this component's location where the Marker Actor should be attached.
Add the
Combat.Component.TargetLockAnchor
tag to the component.
Configure the Target Lock Input
Create a new Input Action for the Target Lock input. Add a Pressed trigger to it.
Add the new Input Action to your Input Mapping Context asset, mapping it to an appropriate key.
Create a new Input Handler or add one directly to your Input Setup, using the Activate Ability by Tags as base.
Add
Ability.TargetLock
to the Ability Tags.Set Toggle Activation, so the ability is activated and then deactivated on input.

Test Everything
Hit Play and test the target lock by pressing the appropriate key.
Capture the correct target via camera aiming, and also by proximity.