Recipe: Dodge Roll Walkthrough¶
Goal: Build a complete dodge roll ability with:
- Stamina cost (-20)
- Cooldown (0.5 seconds)
- I-frames (invulnerability during the roll)
- Animation montage
- Input binding
This walks through the full process end-to-end.
Step 1: Create the Cost GE¶
Asset: GE_Cost_Stamina_20
- Right-click > Gameplay Effect
- Duration Policy: Instant
- Modifiers: Add one modifier:
- Attribute:
MyAttributeSet.Stamina - Modifier Op:
Add (Base) - Magnitude:
-20(negative = costs stamina)
- Attribute:
That's it for the cost. No tags, no cue.
Step 2: Create the Cooldown GE¶
Asset: GE_Cooldown_DodgeRoll
- Right-click > Gameplay Effect
- Duration Policy: Has Duration
- Duration Magnitude:
0.5(seconds) - Tags granted to target (via TargetTagsGameplayEffectComponent):
Cooldown.Ability.DodgeRoll
- Asset Tags (via AssetTagsGameplayEffectComponent):
Cooldown.Ability.DodgeRoll
The cooldown tag is what GAS checks -- while this tag is present, the ability can't activate.
Step 3: Create the Ability Blueprint¶
Asset: GA_DodgeRoll
- Right-click > Blueprint Class > your base ability class
- Name:
GA_DodgeRoll
Class Defaults¶
| Property | Value |
|---|---|
| Ability Tags | Ability.Movement.DodgeRoll |
| Activation Blocked Tags | CrowdControl.Stun, State.Dead, State.DodgeRolling |
| Activation Owned Tags | State.DodgeRolling, State.Invulnerable |
| Block Abilities with Tag | Ability.Combat (can't attack while rolling) |
| Instancing Policy | InstancedPerActor |
| Net Execution Policy | LocalPredicted |
| Cost Gameplay Effect | GE_Cost_Stamina_20 |
| Cooldown Gameplay Effect | GE_Cooldown_DodgeRoll |
Activation Owned Tags for I-frames
State.Invulnerable is granted when the ability activates and removed when it ends. Your damage pipeline checks for this tag and skips damage if present. This is the i-frame mechanism. State.DodgeRolling blocks re-activation during the roll.
Event Graph¶
Event ActivateAbility
│
├─ Commit Ability
│ └─ [Branch: Failed] → End Ability (Cancelled = true)
│
└─ [Branch: Success]
│
├─ Play Montage And Wait
│ ├─ Montage: DodgeRoll_Montage
│ ├─ Rate: 1.0
│ └─ Section: (leave empty for full montage)
│
├─ On Completed → End Ability (Cancelled = false)
├─ On Blend Out → End Ability (Cancelled = false)
├─ On Interrupted → End Ability (Cancelled = true)
└─ On Cancelled → End Ability (Cancelled = true)
Commit Ability does two things:
- Checks if the cost can be paid and the cooldown is ready
- Deducts the cost and applies the cooldown
If it fails (not enough stamina, still on cooldown), the ability ends immediately.
Step 4: Set Up the Montage¶
- Create or use an existing dodge roll animation montage
- Make sure it's set up to play on the appropriate slot (usually FullBody)
- Duration should be around 0.5-0.8 seconds for a responsive feel
Optional: Add anim notifies for:
- A GameplayCue (Burst) notify at the moment feet leave the ground for a dust puff
- A notify to trigger root motion (or use the animation's root motion)
Step 5: Wire Input¶
Follow the Bind Ability to Input recipe:
- Input Action:
IA_Dodge(bool, Pressed trigger) - Input Mapping Context: Map to your dodge key (e.g., Space bar, B button)
- InputTag:
InputTag.Dodge - On the ability: Set InputTag to
InputTag.Dodge
Step 6: I-Frame Integration¶
In your damage pipeline, check for invulnerability before applying damage:
// In PostGameplayEffectExecute or ExecCalc
UAbilitySystemComponent* TargetASC = Data.Target.GetAbilitySystemComponent();
if (TargetASC && TargetASC->HasMatchingGameplayTag(
FGameplayTag::RequestGameplayTag(TEXT("State.Invulnerable"))))
{
// Skip damage
SetIncomingDamage(0.f);
return;
}
Or use the Immunity system: create an Infinite GE that the dodge ability applies, which uses the ImmunityGameplayEffectComponent to block damage effects. This is cleaner but more setup.
Step 7: Test¶
Basic Test¶
- PIE
- Press dodge key → character should play roll animation
- Stamina should decrease by 20
- Press dodge again immediately → should not activate (cooldown)
- Wait 0.5s → dodge should work again
I-Frame Test¶
- Set up a damage source (enemy attack or debug command)
- Time the damage to hit during the roll
- Verify no damage is taken during the roll
- Verify damage works normally outside the roll
Edge Cases¶
- Dodge at 0 stamina → should fail (Commit Ability returns false)
- Dodge while stunned → should fail (Activation Blocked Tags)
- Dodge while already dodging → should fail (
State.DodgeRollingin blocked tags) - Network test: dodge on client, verify prediction feels responsive
Full Assembly Diagram¶
Player presses Dodge key
│
▼
Input System: IA_Dodge → InputTag.Dodge → ASC looks for matching ability
│
▼
GA_DodgeRoll.ActivateAbility()
├─ Check: Activation Blocked Tags (stun? dead? already rolling?)
├─ Commit: GE_Cost_Stamina_20 applied (instant, -20 stamina)
├─ Commit: GE_Cooldown_DodgeRoll applied (0.5s duration)
├─ Tags granted: State.DodgeRolling, State.Invulnerable
├─ Play DodgeRoll_Montage
│ ├─ [Frame 5] AnimNotify: GameplayCue.Movement.DodgeDust
│ └─ [Montage ends]
├─ Tags removed: State.DodgeRolling, State.Invulnerable
└─ End Ability
Related¶
- Common Abilities -- more ability patterns
- Cooldowns and Costs -- cost/cooldown deep dive
- Ability Tasks -- PlayMontageAndWait details
- Damage Pipeline -- where i-frames are checked