CrimsonCamera · Lesson 5 of 6

Data-Driven Lock-On

Advanced6 minGameplayAI

Before you start

  • Completed: Your First Camera
  • At least one lockable actor in the level
Video coming soon

Chapters

How the pipeline works

Lock-on is built on Unreal's Gameplay Targeting System, so who can I lock is a data-driven, reorderable pipeline rather than hard-coded. The component runs a targeting request, the preset's tasks filter and sort candidates, the component picks the best result and a lock point on it, then it pushes UCrimsonCameraMode_LockOn to frame the target — and re-resolves each tick, breaking the lock if the target is gone, out of range, or out of sight.

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.

Data-driven, no recompile
Reorder, add, or disable tasks to change targeting with no recompile. The Team Affiliation filter lives in CrimsonCore — on the full Crimson stack it's available automatically; standalone, drop in your own affiliation filter or omit it. CrimsonCamera never depends on a team plugin.

2. Create a lock-on config

UCrimsonLockOnConfig bundles the targeting preset, the lock-on camera mode class (make a Blueprint child of UCrimsonCameraMode_LockOn), an owner tag, and tunables like MaxLockDistance and SwitchDeadzone.

3. Add the components and lock points

Put a UCrimsonLockOnComponent on the player (assign the config), and a UCrimsonLockOnTargetComponent on each lockable actor. Fill the target's LockOnPoints with mesh sockets — several sockets make a boss's weak points cycle-able.

cpp
// Player pawn:
LockOn = CreateDefaultSubobject<UCrimsonLockOnComponent>(TEXT("LockOn"));
// Lockable actor (fill LockOnPoints in the Details panel):
LockOnTarget = CreateDefaultSubobject<UCrimsonLockOnTargetComponent>(TEXT("LockOnTarget"));
The full stack auto-wires this
On the CrimsonCore stack, players and NPCs already get a health-gated lockable component, so you only author the preset + config and bind input.

4. Bind input

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

cpp
LockOn->ToggleLockOn();
LockOn->SwitchTargetInScreenDirection(RightStick); // X = right, Y = up
LockOn->CycleLockPoint(+1);
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.