Melee Trace

Documentation Unreal Engine AI Melee Combat

Frame-rate independent swept weapon traces with per-window damage configs and ISECDamageable integration.


Each active frame, USECMeleeTraceComponent sweeps from the last socket positions to the current ones. Fast swings still register hits at 30 or 144 FPS.
Viewport
Interpolation OFF
LVL_SEC_Showcase>Melee Trace
Swing Speed60°
SIM_FPS: 10
STATUS: TUNNELING
0
Successful Hits
Without Interpolation: The fast sword swings 'teleport' over the target between frames, causing a miss.

When to Use This

  • Melee on AI or player pawns.
  • Swings that outrun per-frame overlap checks.
  • Several hit zones on one weapon (blade, pommel).
  • Different damage per montage window through SECDamageConfig.
AEnemyCharacterBase ships with USECMeleeTraceComponent. Add SEC Melee Trace to any other pawn you want in the pipeline.

How It Works

Register trace sockets on the wielder (usually when the weapon equips). StartTracing captures socket positions and enables tick. Each tick sub-steps between previous and current transforms and sweeps sphere, capsule, or two-point capsule shapes (SubStepDistance, MaxSubSteps).
ShapeUse
SphereFists, small contact points.
CapsuleSingle-socket volume aligned to bone rotation.
CapsuleTwoPointSpan between two mesh sockets (typical sword blade).
The first tick after StartTracing records positions only; sweeps begin once a previous sample exists.
Hit order:
  1. TeamFilter and duplicate checks (CanHitActor, owner ignored).
  2. OnMeleeHit with FMeleeHitData (contact VFX/SFX hook).
  3. ISECDamageable: BuildDamageInfoApplyDamageHandleDamageResultOnMeleeHitResponse.
  4. No interface: RecordHit, ApplyPointDamage (CurrentDamage, DamageTypeClass), OnMeleeHitResponse with bDamageApplied = true.
StartTracing and tick body return early without authority. StopTracing clears active sockets, hit records, and disables tick.

Setup

1. Component on the wielder

Details
SEC Melee Trace Component (SECMeleeTraceComponent)
Damage
Default Damage Config
None
Base Damage
10
Hit Reset Interval
0
Team Filter
No Filter
Trace
Sub Step Distance
10
Max Sub Steps
20
Debug
Draw Debug
Debug Draw Duration
0.1
Default component on the enemy pawn. Add SEC Melee Trace to other wielders manually.
Set Default Damage Config or Base Damage when a notify omits damage.

2. Weapon mesh sockets

Add sockets on the weapon mesh (example: blade_start, blade_end).

3. Weapon Blueprint

Subclass ASECWeaponBase, fill TraceSockets. OnEquipped assigns SourceComponent to the weapon mesh and calls RegisterTraceSocket_Struct on the wielder's trace component.
Details
Weapon Trace Socket (FSECTraceSocket)
SEC|Weapon
Attach Socket
hand_r
SEC|Trace
ID
Blade
Shape
Capsule Two Point
Socket Or Bone Name
blade_start
End Socket Or Bone Name
blade_end
Radius
15
Trace Channel
Pawn
One TraceSockets array entry on the weapon Blueprint. OnEquipped registers sockets on the wielder trace component.
Per-attack damage comes from the montage notify or component default, not the weapon actor.

4. Damage config

Create SECDamageConfig, assign on the notify or Default Damage Config:
Details
SEC Damage Config (SECDamageConfig)
Damage
Damage
10
Damage Type
None
Forces
Hit Bone Force
0
Hit Overall Force
0
Hit Rotational Force
0
Data asset assigned on the montage notify or the trace component Default Damage Config.
Per window: notify Damage ConfigDefault Damage ConfigBase Damage. StartTracingSimple accepts a numeric override; values below zero fall back to Base Damage.

5. Montage window

Add Notify State → SEC Melee Trace Window on strike frames:
Details
SEC Melee Trace Window (SECMeleeTraceNotifyState)
Melee Trace
Socket IDs
1 Array element
Damage Config
DA_SwordDamage
Debug
Enable Debug Draw
Anim notify state on strike frames. Empty Socket IDs activates every registered socket.
Empty Socket IDs activates every registered socket. Names must match each trace socket ID.
Animation montage with SEC Melee Trace Window notify state
Equip, play the montage: register on equip, StartTracing at notify begin, StopTracing at notify end.

Integration

SystemLink
Reaction SystemApplyDamage returns ResultTags for reaction selection.
MultiplayerTrace and damage on authority; clients follow replicated state.
Configuration ReferenceShared project tuning (reconcile damage fields with this page).
TeamFilter on the trace component (damage gating, not combat target selection):
Details
SEC Melee Trace Component (SECMeleeTraceComponent)
Damage
Team Filter
No Filter
Damage category on the wielder trace component. Filters who can be hit, separate from combat target selection.

AdvancedDelegates and manual control
void StartTracing(const TArray<FName>& SocketIDs, USECDamageConfig* DamageConfig = nullptr, bool bDebugOverride = false);
void StartTracingSimple(const TArray<FName>& SocketIDs, float DamageOverride);
void StopTracing();
 
void RegisterTraceSocket_Struct(const FSECTraceSocket& TraceSocket);
void UnregisterTraceSocket(FName ID);
void UnregisterAllSockets();  // weapon swap: stock OnUnequipped does not call this
OnMeleeHit: FMeleeHitData (HitResult, FromSocketID, DamageConfig).
OnMeleeHitResponse: FMeleeHitData + FSECDamageResult.
Subclass BuildDamageInfo or HandleDamageResult for crit scaling, pierce, or custom hit recording.
Blueprint helpers: RegisterSphereSocket, RegisterCapsuleSocket, RegisterTwoPointCapsule.
AdvancedISECDamageable pipeline
FSECDamageInfo: Instigator, HitResult, HitDirection, DamageDefinition (ToDamageDefinition() when a config is active).
FSECDamageResult: bDamageApplied, ResultTags.
HandleDamageResult recording:
ResultRecording
bDamageApplied = trueRecordHit (blocks repeat hits this window when HitResetInterval is 0).
bDamageApplied = false, tags match SkipRecordTagsNo record (dodge: try again next frame).
bDamageApplied = false, other tagsRecordHit (parry/block consumes the swing).
bDamageApplied = false, empty tagsNo record (ignored stimulus).
HitResetInterval: 0 allows one recorded hit per target per window. Above 0, the same target can register again after that many seconds; expired records purge each tick.
AdvancedDebug
SEC.Debug.Melee.DrawTracing 1
Component Draw Debug, or notify Enable Debug Draw for one window (bSessionDebugOverride).
AdvancedCommon issues
ProblemLikely causeFix
No hitsSocketIDs ≠ socket IDMatch FName strings.
No hitsSockets missingEquip via ASECWeaponBase::OnEquipped; wielder needs trace component.
Miss first active frameWarm-up tickNormal: sweep needs a prior position sample.
Through wallsTraceChannelPick a channel blocked by world geometry.
Two hits one swingTwo sockets touchExpected; narrow active SocketIDs or shapes.
No damage on SEC pawnNo interfaceImplement ISECDamageable.
Client swing, no damageNo authorityStartTracing / tick skip non-authority owners.