Author a Melee Attack
This page builds the smallest melee hit: one attack definition, one Trace, a sweep during the open window, then UGCS_CombatFunctionLibrary writes the attack definition into the Effect Context and applies a Gameplay Effect. The target's Combat Flow collects that into an Attack Result.
Related pages: if the Flow still has no Result, start with Register the First Attack Result. The request model is in Attack Definitions and Requests; window behavior is in Traces and Hit Windows.
Prerequisites
- You attached
UGCS_CombatSystemComponentandUGCS_TraceSystemComponentand implemented the combat-entity interface from Attach Combat Components. The target Flow already registers a Result from the attribute callback, as in Register the First Attack Result. - The authority already called
InitializeAbilitySystem. - You have an instant Gameplay Effect that changes a target attribute. For local predicted feedback, add
UGCS_GEComponent_PredictivelyExecuteto that effect. - Attacker and target collision channels can sweep each other.
1. Author the attack definition
Create a Data Table with row type GCS Attack Definition (FGCS_AttackDefinition). Fill one row:
AttackTagssuch as melee or light attack. Those tags become dynamic AssetTags on the Effect Spec.TargetEffectClass: the instant GE from above. AddTargetEffectContainerwhen you need more effects; both apply independently when set.- Leave knockback, cues, and extensions empty for this page.
Save the Data Table row handle. UGCS_AttackRequest_Melee points at it later.
2. Author the Trace definition
Create another Data Table with row type FGCS_TraceDefinition:
TraceTag: the identifier the window uses to start this Trace.CollisionShape: a static sphere or capsule large enough for the swing.SweepSetting: the channel, object types, or profile must match the target collision. The defaultVisibilitychannel often misses a character capsule.
Put that TraceTag in the melee request's TracesToControl. StartTraces only starts tags listed in the container.
3. Fill the melee request
Create UGCS_AttackRequest_Melee, or embed it on the notify:
Field | This page |
|---|---|
| The attack-definition row from step 1 |
| The |
The request describes which row this window uses and which Traces to open. It is not a runtime executor.
4. Open the window with the Task
In the combat ability:
- Call
HandleCollisionTracesto getUGCS_AbilityTask_CollisionTrace. - At window start,
AddMeleeRequest(Request, SourceObject).SourceObjectcan be the weapon or the pawn; it correlates the Trace handle. - Bind
OnTargetsFound. On a hit, useUGCS_CombatFunctionLibraryto writeAttackDefinitionHandleinto the Effect Context (Set Attack Definition HandleorAddAttackHandleToGameplayEffectSpec), then apply the GE to the target. - Call
RemoveMeleeRequestwhen the window ends. Destroying the Task also stops leftover Traces.
You can place GCS_ANS_AttackTrace on the montage and fill the same melee request. The notify only stores the request. The Collision Trace Task still has to read it and call AddMeleeRequest. An ANS without a Task never sweeps.
Expected result
While the window is open, the Debugger Trace section shows the handle as active. A sweep broadcasts OnTargetsFound. After you apply a GE with the attack handle, the target's Attack Result section shows the latest result.
Verify
- In PIE, open the Combat category of Gameplay Debugger: Shared already has the combat component; after one hit, Trace shows the handle and active state.
- Attack Result shows the latest result plus prediction and replication flags.
Get Attack Definition Handleon the Effect Context returns the row from this page.- Set
LogGCS_Trace/LogGCS_Combatto Verbose to see sweeps and resolution. - In multiplayer PIE, confirm the server produces a result before checking that LocalPredicted processors on the AutonomousProxy run only once.
Common failures
Symptom | Check first |
|---|---|
Animation plays, no hit | Trace component present; ANS is only a data container and the Task never started; |
Task warns No any trace started | |
Sweep hits nothing | |
Effect has no attack context | CombatFunctionLibrary wrote the handle; Globals class is GGA |
Window never opens | |
Next
After the melee loop works, continue with Author a Ranged Attack, or put this hit in a combo table with Configure Combo and Weapon. Failures: Debugging and Troubleshooting.