Hit Tracing¶
The Hit Tracing System detects weapon and body part collisions using socket-based traces. Multiple trace profiles can be registered independently, each with its own mesh, sockets, and trace method. Animation notifies control when traces are active.
Architecture¶
+---------------------------+
| UHitTraceActorComponent |
+---------------------------+
|
v
+---------------------------+
| TraceProfiles (TMap) |
+---------------------------+
| Tag: Trace.Weapon.Right |-----> FHitTraceProfile
| TraceMesh: WeaponMesh | +--SocketNames[]
| TraceMethod: OverTime | +--LastSocketLocations{}
| | +--bIsActive
| Tag: Trace.Weapon.Left |-----> FHitTraceProfile
| TraceMesh: OffhandMesh | ...
| |
| Tag: Trace.Body.Hand.R |-----> FHitTraceProfile
| TraceMesh: CharacterMesh| ...
+---------------------------+
|
v (when active)
+---------------------------+
| TickComponent() |
| - TraceSameSocketOverTime |
| - TraceBetweenSockets |
+---------------------------+
|
v (on hit)
+---------------------------+
| OnItemAdded.Broadcast() |
+---------------------------+
|
v
+---------------------------+
| UCombatComponent |
| ::OnActorHit() |
+---------------------------+
Why This Design?¶
Profile-Based Architecture¶
Instead of hardcoding "weapon trace" and "body trace," the system uses tagged profiles. This allows: - Multiple weapons (dual-wield) with independent traces - Body part traces for unarmed combat - Easy addition of new trace sources (tails, wings, etc.)
Socket-Based Tracing¶
Traces use mesh sockets rather than bones or fixed offsets. This means: - Weapon artists can place sockets for optimal trace coverage - Different weapons can have different socket layouts - No code changes needed for new weapon shapes
Delta-Time Tracing¶
Traces compare positions between frames rather than checking a single point. This catches fast-moving weapons that might teleport through targets in a single frame.
A Swing Reaches the Same at Any Frame Rate¶
The Steam Deck is a release target, so what a swing can reach must not depend on the frame rate. A blade tip moves up to 205 cm in one 30 fps frame, and two things go wrong at that speed if a sweep simply joins one frame to the next:
- A straight line cuts inside the arc. Each stretch between two frames is bent along the weapon's turn: the mesh's location and rotation are interpolated between the two real poses, which carries every socket round its arc. A stretch is split into pieces of at most
Eternal.Combat.HitTrace.ArcSegmentcm (40), up to 16 per frame. The arc is an estimate of the path between two real poses, and it passes through both. - A window's edges fall between frames. Its first frame lands anywhere after the authored start, and a notify state ends the tick after its range is passed, so the window stays open a frame past its authored end. The sweep is cut at both authored edges by montage position.
Cutting at the opening edge needs a pose from before it, which no notify can give. So the component samples the weapon from the moment a montage with a hit window starts (OnMontageStarted, authority only), and the trace profile holds the latest pose ready. Enemy meshes that only update when rendered are forced to refresh for the same span, the whole swing rather than the window. This is also what makes the first pose a true one on a server: forcing at the window's opening left the first sweep starting from a pose the weapon held long before.
A window that cannot use this sweeps as before, from its first frame to the first frame past its end: a notify placed on a sequence rather than on the montage, or a window that opens and closes inside one frame.
Eternal.Combat.HitTrace.FullWindow 0 and ArcSegment 0 switch both off for comparison.
Trace Methods¶
The system supports three trace methods for different use cases:
SameSocketOverTime (Default)¶
Traces from each socket's previous position to its current position.
Frame N: Socket_01 at position A
Frame N+1: Socket_01 at position B
Trace: A =================> B
Best for: Swinging weapons, following arc of attack
BetweenSocketsSameTime¶
Traces between different sockets in the same frame.
Frame N:
Socket_01 =================== Socket_02
|| ||
|| ||
Socket_03 =================== Socket_04
Best for: Blade edges, polearm shafts
BetweenSocketsDifferentTime¶
Traces from each socket's current position to other sockets' previous positions.
Frame N: Socket_01(A) Socket_02(B)
Frame N+1: Socket_01(C) Socket_02(D)
Traces: C ---------> B
D ---------> A
Best for: Maximum coverage on fast attacks
Trace Profile Configuration¶
FHitTraceProfile Properties¶
| Property | Type | Purpose |
|---|---|---|
TraceMesh |
UPrimitiveComponent* | Mesh containing trace sockets |
SocketNames |
TArray |
Explicit sockets (empty = all sockets) |
TraceMethod |
ETraceMethod | Which trace algorithm to use |
SkipStringFilter |
FString | Exclude sockets with this substring |
InclusionStringFilter |
FString | Only include sockets with this substring |
bIsActive |
bool | Whether currently tracing |
LastSocketLocations |
TMap |
Previous frame positions |
Profile Tags¶
| Tag | Typical Use |
|---|---|
Trace.Weapon.Right |
Main hand weapon |
Trace.Weapon.Left |
Off-hand weapon |
Trace.Body.Hand.Right |
Right fist (unarmed) |
Trace.Body.Hand.Left |
Left fist (unarmed) |
Trace.Body.Foot.Right |
Kick attacks |
Trace.Body.Foot.Left |
Kick attacks |
How Tracing Works¶
Registration Flow¶
Weapon equipped
|
v
EquipmentComponent spawns weapon actor
|
v
Get weapon's SkeletalMeshComponent
|
v
HitTraceActorComponent::RegisterTraceProfile()
|
+---> Create FHitTraceProfile
+---> Store in TraceProfiles map
+---> Profile starts inactive
Activation Flow¶
Attack montage starts (authority)
|
v
OnOwnerMontageStarted
|
+---> Find the montage's hit windows and their profiles
+---> Force bone refresh on those meshes
+---> Tick on: record each profile's pose every frame
|
v
ComboHitWindow notify begins
|
v
ToggleTraceCheck(true, ProfileTag, WindowStart, WindowEnd)
|
+---> Find profile by tag
+---> Set bIsActive = true
+---> Keep the recorded pose as the sweep's start
+---> Add to ActiveProfileTags
+---> Set CanTrace = true
|
v
TickComponent runs traces, cut at the window's edges
|
v
ComboHitWindow notify ends
|
v
ToggleTraceCheck(false, ProfileTag)
|
+---> Deactivate profile
+---> Clear hit array once no window is left open
|
v
Montage stops
|
+---> Restore the meshes' refresh settings
+---> Tick off
Hit Detection Flow¶
TickComponent()
|
v
For each active profile:
|
+---> Get filtered sockets
+---> Execute trace method
|
v
PerformTrace(Start, End)
|
+---> Check distance threshold
+---> Execute shape trace (sphere/box/capsule/line)
|
v
For each hit result:
|
+---> Already hit this actor? -> Skip
+---> Add to HitArray
+---> OnItemAdded.Broadcast(HitResult)
Trace Shape Configuration¶
| Property | Type | Default | Purpose |
|---|---|---|---|
TraceType |
EKismetTraceType | LineTrace (players and enemies use CapsuleTrace) | Shape of trace |
SphereRadius |
float | 0 | Radius for sphere traces |
BoxHalfSize |
FVector | (0,0,0) | Half-extents for box traces |
CapsuleRadius |
float | 0 (players and enemies use 25) | Radius for capsule traces |
CapsuleHalfHeight |
float | 0, which makes the capsule a sphere | Half-height for capsule traces |
bTraceComplex |
bool | true | Use complex collision |
bIgnoreSelf |
bool | true | Ignore owning actor |
Animation Integration¶
The ComboHitWindow notify state controls trace activation:
Montage Timeline:
|---[Startup]---|---[Active Frames]---|---[Recovery]---|
| |
| <-- HitWindow --> |
| |
NotifyBegin() NotifyEnd()
| |
v v
ToggleTrace(true) ToggleTrace(false)
ComboHitWindow Properties¶
| Property | Purpose |
|---|---|
WeaponTraceTag |
Which profile to activate |
bIsFinalHit |
Mark last hit in combo |
HitDamageMultiplier |
Optional per-hit damage modifier |
Duplicate Prevention¶
The system prevents hitting the same actor multiple times per attack:
New hit detected
|
v
HitArray.ContainsByPredicate(
[&](FHitResult& Existing) {
return Existing.GetActor() == Hit.GetActor();
}
)
|
+----+----+
| |
Found Not Found
| |
v v
Skip Add to array
Broadcast
The HitArray is shared by every open window, so a blow that lands through two weapons hits a target once. It is cleared when the last open window closes. Windows close independently: one ending leaves the others sweeping.
Key Contracts¶
UHitTraceActorComponent API¶
| Method | Parameters | Purpose |
|---|---|---|
RegisterTraceProfile() |
Tag, Mesh, Sockets, Method, Filters | Create new trace profile |
UnregisterTraceProfile() |
Tag | Remove profile |
UpdateProfileMesh() |
Tag, NewMesh | Change profile's trace mesh |
ToggleTraceCheck() |
bTrace, Tag, WindowStartTime, WindowEndTime | Enable/disable specific profile; the times are the window's on the montage clock, and negative means unknown |
ClearAllActiveTraces() |
- | Stop all tracing, clear hits |
OnItemAdded Delegate¶
| Parameter | Type | Contents |
|---|---|---|
LastItem |
FHitResult | Hit location, actor, component, bone |
Source References¶
| Concept | File | Line |
|---|---|---|
| UHitTraceActorComponent class | Source/ProjectEternal/Public/Combat/Components/HitTraceActorComponent.h | 30 |
| FHitTraceProfile struct | Source/ProjectEternal/Public/Combat/Components/HitTraceActorComponent.h | 15 |
| ETraceMethod enum | Source/ProjectEternal/Public/Combat/Components/HitTraceActorComponent.h | 10 |
| TraceSameSocketOverTime() | Source/ProjectEternal/Private/Combat/Components/HitTraceActorComponent.cpp | 150 |
| RegisterTraceProfile() | Source/ProjectEternal/Private/Combat/Components/HitTraceActorComponent.cpp | 60 |
| ToggleTraceCheck() | Source/ProjectEternal/Private/Combat/Components/HitTraceActorComponent.cpp | 100 |
| ComboHitWindow notify | Source/ProjectEternal/Public/Combat/AnimNotifies/ComboAnimNotifies.h | 10 |
| Arc geometry and edge cuts | Source/ProjectEternal/Public/Combat/Types/HitTraceArc.h | 6 |
Related Documentation¶
- Combat Overview - Hit processing in CombatComponent
- Combo System - Hit window timing
- Combat Animation - Animation notify setup
Measuring¶
Tools/Harness/scenarios/hit_trace_path.py records a weapon's true path with the world slowed to a tenth, one sample every 2–3 ms. Tools/Harness/hit_trace_sim.py replays that path at a game frame rate and reports which standing targets each sweep rule would miss. hit_trace.py and hit_trace_log.py read the real sweep's segments, and hit_trace_enemy.py does the same for an enemy.
hit_trace_reach.py swings at real dummies under both rules. A lone dummy shows nothing, because the aim assist faces it, and a bystander can be shoved by the lunge's capsule, so judge a surprising result against slow=0.1, which samples the swing finer than any frame rate.
Recent Changes¶
- Sweeps cover the authored window at any frame rate: arcs between frames, cuts at both window edges, the swing sampled from the montage's start.
- Profiles are the only trace path: the plugin's original socket tracing and its
My*settings are gone. - Profile mesh can be updated dynamically:
UpdateProfileMesh()allows changing the traced mesh without re-registering (useful for weapon swapping). - Socket filtering improved: Both skip and inclusion filters can be applied simultaneously for precise socket selection.