CMCharacter Modules 0.1.0

Lock On

Kind: Modifier · Add Component: Character Modules > Modifiers > Lock-On

Keeps the character facing a target and circling it. Fighting one enemy among many stays manageable.

Locks the character onto a target: the body faces it, and moving circles around it. Fighting one enemy among many becomes manageable.

Inspector
▼Lock On⋮
CharacterCharacter (Character Motor)
Finding a target
Acquire Range20
Acquire Angle60
Break Range25
Lost Sight Time1
Sight MaskDefault, TransparentFX, 3, Water, UI, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ▾
Looking while locked
LookSwitch Targets ▾
Switch Flick8
In Line Angle8
Switch Cooldown0.3
Recenter Delay0.8
Moving while locked
Sideways Scale0.65
Back Scale0.5
View Turn Rate540
Pitch Offset15
Pitch Distance4
Max Pitch25
The Lock On component in the Inspector, with its defaults.
Origin. Z-targeting in The Legend of Zelda: Ocarina of Time (1998); Dark Souls (2011) made it the genre's standard.

How it works

Changes the Walking mode: locked on: faces the target, slower sideways and back. Changes Dodge: locked on: rolls around the target, facing it.

Lock-On: press Lock On to pick the target nearest the middle of the view (within reach and in sight), as in melee action role-playing games. While locked, the view turns to the target, so the stick moves relative to it: sideways circles it, back retreats from it. The body keeps facing the target, and moving sideways or back is slower. While sprinting the body turns toward the run instead, and faces the target again after. A dodge rolls any way around the target, still facing it. The camera keeps the target in frame (see CameraTarget.focus).

Looking while locked: with Switch Targets (as in the games) a flick of the mouse or the right stick moves the lock to the next target that way, and the view stays on the target; with Free Look the view goes where you look and turns back to the target after recenterDelay.

Press again to let go; the lock also breaks beyond breakRange or when the target has been out of sight for lostSightTime. With no target in reach, a press turns the view to where the body faces.

Combine it

  • Used by the presets: Action RPG.

Properties

PropertyDescriptionRangeDefault
CharacterThe character this module belongs to. Drag its Character Motor here.None
Acquire RangeFarthest target a press can pick, metres.0 or more20
Acquire AngleWidest angle from the view's direction at which a press can pick a target, degrees.0 to 18060
Break RangeThe lock breaks when the target is farther than this, metres.0 or more25
Lost Sight TimeThe lock breaks after the target has been out of sight this long, seconds.0 or more1
Sight MaskLayers that block the sight of a target.Default, TransparentFX, 3, Water, UI, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
LookSwitch Targets: a flick moves the lock to the next target. Free Look: look freely, the view returns later.Switch Targets
Switch FlickSwitch Targets: a flick at least this big switches, degrees of view turn.0.1 or more8
In Line AngleSwitch Targets: targets within this angle of the smallest turn count as in line; the nearest wins, degrees.0 to 458
Switch CooldownSwitch Targets: seconds after a switch before the next flick counts.0 or more0.3
Recenter DelayFree Look: seconds without looking before the view turns back to the target.0 or more0.8
Sideways ScaleSpeed scale moving straight sideways, compared with forward.0 to 10.65
Back ScaleSpeed scale moving straight back, compared with forward.0 to 10.5
View Turn RateHow fast the view turns to the target, degrees per second.0 or more540
Pitch OffsetThe view looks this much further down than straight at the target, degrees.15
Pitch DistanceThe view's tilt is worked out as if the target were at least this far, so a near one does not tip it, metres.0.1 or more4
Max PitchThe lock tilts the view at most this far up or down, degrees.0 to 8025

Additional resources