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.
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.
| # | Task | What it contributes |
|---|---|---|
| 1 | UTargetingSelectionTask_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. |
| 2 | Crimson Lock-On Filter: Require Lockable | Drops any actor without a UCrimsonLockOnTargetComponent, or whose CanBeLockedOnBy answered no. |
| 3 | Crimson Lock-On Filter: Frontal Cone | Culls 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. |
| 4 | Crimson Lock-On Filter: Line Of Sight | Traces on TraceChannel and drops targets standing behind geometry. |
| 5 | Crimson Lock-On Sort: Screen Center | Sort. 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. |
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.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:
| Property | Set it to |
|---|---|
TargetingPreset | The preset from step 1. Drives hard lock. |
SoftTargetingPreset | Optional second preset used only by soft lock. Leave it unset to reuse TargetingPreset. |
LockOnCameraModeClass | Your Blueprint child of UCrimsonCameraMode_LockOn. Leaving this unset means lock-on has no camera to push. |
CameraOwnerTag | The override-stack tag the lock-on mode is pushed under, for example Camera.Mode.LockOn. |
MaxLockDistance | Distance in cm at which the lock drops. Default 2500. |
SwitchDeadzone / SwitchCooldown | How far the stick must move before a switch counts (0.5) and the minimum seconds between switches (0.25). |
bBreakOnLineOfSightLost | Tick to drop the lock the moment the target goes behind geometry; LineOfSightChannel picks the trace channel for that check. |
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.
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.
See also
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.