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
Why the interface is required
Section titled “Why the interface is required”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. Add the interface
Section titled “1. Add the interface”- Open your enemy / NPC Character Blueprint (must have a Skeletal Mesh component).
- Class Settings → Interfaces → Add → BPI_AutoAim (
Blueprints/Main/BPI_AutoAim). - Compile — Unreal adds Get Skeletal Mesh Component to implement.
2. Implement Get Skeletal Mesh Component
Section titled “2. Implement Get Skeletal Mesh Component”In Get Skeletal Mesh Component:
- Get Mesh (character skeletal mesh component).
- Return it on the function output.
3. Sockets
Section titled “3. Sockets”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.
4. Trace object types
Section titled “4. Trace object types”Default Types To Trace is Pawn only. Targets must be Character / Pawn actors, or you must add their object type to Types To Trace.
5. Exclude actors from traces
Section titled “5. Exclude actors from traces”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.
1. Open the reference Blueprint
Section titled “1. Open the reference Blueprint”Path: Content/AutoAimComponent/Blueprints/ThirdPersonCharacter_NPC
- Parent class: Character
- Graphs include GetSkeletalMeshComponent (interface implementation)
2. Verify interface
Section titled “2. Verify interface”- Class Settings → Interfaces — BPI_AutoAim is listed.
- Open Get Skeletal Mesh Component — returns Mesh component.
3. Place in your test map
Section titled “3. Place in your test map”- Drag ThirdPersonCharacter_NPC into your level (or duplicate the setup from AutoAimComponentExampleMap).
- Ensure your player has the lock-on wiring.
4. Playtest checklist
Section titled “4. Playtest checklist”| Step | Expected result |
|---|---|
Hold Start Targeting on NPC at < 3000 units | On Auto Aim Started fires |
| Camera while held | Smooth rotation toward closest socket |
| Release Start Targeting | On Auto Aim Ended fires |
| Aim at floor, press Start Targeting | On Auto Aim Failed |
5. Example — duplicate for a new enemy
Section titled “5. Example — duplicate for a new enemy”- Duplicate ThirdPersonCharacter_NPC →
BP_MyShooterEnemy. - Keep BPI_AutoAim and Get Skeletal Mesh Component unchanged.
- Swap mesh / animations as needed — sockets must exist on the new skeleton.
- Place in level and test lock-on from your wired player.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Check |
|---|---|
| No lock on NPC | BPI_AutoAim added? Mesh returned from interface? |
| Lock fails at range | Within Trace Distance? |
| Wrong body part | Set Override Socket Name or adjust trace aim point |
| Locks through walls | Enable Check Line Of Sight |
- Play the demo — run the reference map
- Use Distance Angle Check + CT_DistanceBasedAngle → Component reference