How-To: Set Up Lock-On

Goal: lock the camera onto a target (with multiple lock points), switch targets by screen direction, and cycle lock points.

Prerequisites
The Gameplay Targeting System is enabled (it is, via CrimsonCamera). You have a pawn with a UCrimsonCameraComponent and at least one lockable actor.

1. Build a targeting preset

The preset decides who can be locked. It's a data asset - author it in the editor; there is no C++ step. Add tasks in order: selection, then filters, then a sort.

Create a Targeting Preset (Content Browser -> right-click -> Miscellaneous -> Data Asset -> Targeting Preset) and fill its targeting task set in this order. Each row is one entry in the tasks array; the pipeline runs top to bottom.

#TaskWhat it contributes
1UTargetingSelectionTask_AOE (Gameplay Targeting System)Selection. Gathers every actor in a shape around the source. A preset with no selection task returns zero candidates - this row is not optional.
2Crimson Lock-On Filter: Require LockableDrops any actor without a UCrimsonLockOnTargetComponent, or whose CanBeLockedOnBy answered no.
3Crimson Lock-On Filter: Frontal ConeCulls anything outside a cone in front of you. Optional for hard lock, required for soft lock. Set ReferenceDirection = CameraView, then tune ConeHalfAngleDegrees, bHorizontalOnly, and MaxConeDistance.
4Crimson Lock-On Filter: Line Of SightTraces on TraceChannel and drops targets standing behind geometry.
5Crimson Lock-On Sort: Screen CenterSort. Ranks what survived by how near the screen center it sits. Swap in the engine's UTargetingFilterTask_SortByDistance if nearest-first suits your game better.
Data-driven
Reorder, add, or disable tasks to change targeting with no recompile. This plugin ships no team filter: to keep only enemies, write your own UTargetingFilterTask subclass that asks your team system for the attitude toward each candidate (the engine's IGenericTeamAgentInterface works), or omit it. (CrimsonCore - requires all Crimson plugins) CrimsonCore ships one, UCrimsonCoreTargetingFilterTask_Affiliation.
Verify
Open the preset - the tasks list reads Selection -> filters -> sort. If there is no selection task it will match nothing; the Crimson.Camera.DevTools Preset tab flags this.

2. Create a lock-on config

UCrimsonLockOnConfig bundles the preset, the lock-on camera mode, and tunables. Make a Blueprint child of UCrimsonCameraMode_LockOn for the mode class.

Create it from the Content Browser: right-click empty space -> Crimson Plugins -> Camera -> Lock-On -> Lock-On Config. Then fill its Details:

PropertySet it to
TargetingPresetThe preset from step 1. Drives hard lock.
SoftTargetingPresetOptional second preset used only by soft lock. Leave it unset to reuse TargetingPreset.
LockOnCameraModeClassYour Blueprint child of UCrimsonCameraMode_LockOn. Leaving this unset means lock-on has no camera to push.
CameraOwnerTagThe override-stack tag the lock-on mode is pushed under, for example Camera.Mode.LockOn.
MaxLockDistanceDistance in cm at which the lock drops. Default 2500.
SwitchDeadzone / SwitchCooldownHow far the stick must move before a switch counts (0.5) and the minimum seconds between switches (0.25).
bBreakOnLineOfSightLostTick to drop the lock the moment the target goes behind geometry; LineOfSightChannel picks the trace channel for that check.
Verify
The config asset has its Targeting Preset and Lock On Camera Mode Class both assigned - an unset mode class means lock-on has no camera to push.

3. Add the components and lock points

Put a UCrimsonLockOnComponent on the player (assign the config), and a UCrimsonLockOnTargetComponent on each lockable actor (fill its LockOnPoints with mesh sockets - several sockets = cycle-able weak points).

On the player pawn: Components -> + Add -> Crimson Lock On Component, then in its Details -> Lock-On set Lock On Config to the asset from step 2. On each lockable actor: Components -> + Add -> Crimson Lock On Target Component, then fill its Lock On Points array - one entry per targetable socket, each with a SocketName (plus an optional DisplayName and Priority). Several entries is what makes a target's weak points cycle-able; leave the array empty and the actor is still lockable, at DefaultPointHeight above its origin.

Verify
In PIE, the Crimson.Camera.DevTools Targets tab lists each lockable actor with Lockable = Yes. An actor missing its target component shows Lockable = No.

4. Bind input

The lock-on component exposes Blueprint-callable actions. Bind your Enhanced Input to them.

Bind three Enhanced Input actions on the pawn, each starting from a Get of its Crimson Lock On Component (it appears in My Blueprint -> Components once you add it). Lock action, Triggered -> Toggle Lock On. Switch action (Axis2D), Triggered -> Switch Target In Screen Direction (Screen Direction = the event's Action Value; X is right, Y is up). Cycle action, Triggered -> Cycle Lock Point (Direction = 1 for the next point, -1 for the previous). Cycle Target (Direction) steps between whole targets the same way, if you prefer that to the screen-direction flick.

Verify
Press lock -> the camera frames the target; flick the switch input -> it swaps to the screen-direction target; cycle -> it re-aims between the target's sockets.

See also

Reading the target from other code
FCrimsonLockOnTargetInfo (Camera/CrimsonLockOnTargetInfo.h) is owned by this plugin. Any gameplay code - an ability, an AI task, a Motion Warping target source - reads the current target by calling GetCurrentLockOnTarget on the pawn's UCrimsonLockOnComponent. It is a virtual function, so a subclass can change what counts as the current target.
  • How-To: Lock-On Indicators - draw the on-screen markers over targets.
  • How-To: Face the Lock-On Target - make the character strafe toward the target (optional).
  • How-To: Soft Lock-On - action-combat continuous targeting on top of this setup.
  • Concept: Lock-On Pipeline - how the targeting preset, component, and camera mode fit together.
  • Lock-On Reference (in API Reference) - the indicator widget, settings, and config flags.