Skip to content

Make an aimable target

Targets must implement BPI_AutoAim so the player’s Get Auto Aim Interface call succeeds. This guide follows ThirdPersonCharacter_NPC from the demo map.

flowchart LR
  Trace["Start Trace box hit"]
  Hit["Hit Target actor"]
  BPI["BPI_AutoAim"]
  Mesh["Skeletal Mesh Component"]
  Socket["Get Socket / Socket Location"]
  Aim["Set Look At Target Location"]

  Trace --> Hit
  Hit --> BPI
  BPI --> Mesh
  Mesh --> Socket
  Socket --> Aim

Start Trace stores the hit actor as Hit Target. Each tick the player calls Get Auto Aim Interface — that only succeeds when the actor implements BPI_AutoAim.

Without it:

  • The interface cast fails
  • Set Look At Target Location never receives a valid socket point
  • On Auto Aim Failed may fire with an error message
  1. Open your enemy / NPC Character Blueprint (must have a Skeletal Mesh component).
  2. Class Settings → Interfaces → AddBPI_AutoAim (Blueprints/Main/BPI_AutoAim).
  3. Compile — Unreal adds Get Skeletal Mesh Component to implement.

In Get Skeletal Mesh Component:

  1. Get Mesh (character skeletal mesh component).
  2. Return it on the function output.

With Override Socket Name = None on the player’s component, Get Socket picks the closest socket to the trace hit.

To force a bone every time, set Override Socket Name on the player’s Auto Aim Component (e.g. your head socket). If the name does not exist on the mesh, aiming fails.

Default Types To Trace is Pawn only. Targets must be Character / Pawn actors, or you must add their object type to Types To Trace.

Call Set Actors To Ignore at Begin Play on the player’s component with the player (and allies) so the trace does not lock onto yourself.

Worked example — ThirdPersonCharacter_NPC

Section titled “Worked example — ThirdPersonCharacter_NPC”

The demo map spawns four NPC instances (ThirdPersonCharacter_NPC_2, ThirdPersonCharacter_NPC2, etc.). All use the same Blueprint.

Path: Content/AutoAimComponent/Blueprints/ThirdPersonCharacter_NPC

  • Parent class: Character
  • Graphs include GetSkeletalMeshComponent (interface implementation)
  1. Class Settings → InterfacesBPI_AutoAim is listed.
  2. Open Get Skeletal Mesh Component — returns Mesh component.
  1. Drag ThirdPersonCharacter_NPC into your level (or duplicate the setup from AutoAimComponentExampleMap).
  2. Ensure your player has the lock-on wiring.
StepExpected result
Hold Start Targeting on NPC at < 3000 unitsOn Auto Aim Started fires
Camera while heldSmooth rotation toward closest socket
Release Start TargetingOn Auto Aim Ended fires
Aim at floor, press Start TargetingOn Auto Aim Failed
  1. Duplicate ThirdPersonCharacter_NPCBP_MyShooterEnemy.
  2. Keep BPI_AutoAim and Get Skeletal Mesh Component unchanged.
  3. Swap mesh / animations as needed — sockets must exist on the new skeleton.
  4. Place in level and test lock-on from your wired player.
SymptomCheck
No lock on NPCBPI_AutoAim added? Mesh returned from interface?
Lock fails at rangeWithin Trace Distance?
Wrong body partSet Override Socket Name or adjust trace aim point
Locks through wallsEnable Check Line Of Sight