Course contentsShow
← Unreal Engine Game Development
Lesson 645 of 8809. Gameplay Ability System (GAS)Free lesson

Implementing Instant and Duration Effect Policies

Master the distinction between Instant, Duration, and Infinite effects to control how long attribute modifications persist on a target character.

In this lesson, you will learn how to leverage Gameplay Effect (GE) duration policies to dictate whether an attribute modification is permanent, temporary, or ongoing.

The Three Pillars of Duration

In the Gameplay Ability System, the DurationPolicy determines how long a GameplayEffect interacts with an AttributeSet.

  1. Instant (EGameplayEffectDurationType::Instant): These effects are applied once and then immediately discarded. They are perfect for one-time events like dealing direct damage or consuming a health potion. Because they have no "state," they do not appear in the active effect list on your AbilitySystemComponent (ASC).
  2. Duration (EGameplayEffectDurationType::HasDuration): These effects persist for a specific length of time defined by a DurationMagnitude. While active, the ASC maintains a handle to the effect, and the attribute modification remains in force until the timer hits zero. This is the standard choice for buffs like a 10-second speed boost.
  3. Infinite (EGameplayEffectDurationType::Infinite): These persist indefinitely until they are explicitly removed by your game logic. They are ideal for persistent status changes, such as equipment stats (e.g., a "Boots of Speed" item) or long-term debuffs like a curse that lasts until cleansed.

Implementing in the Editor

When you create a GameplayEffect Blueprint, you set the Duration Policy in the General section. If you choose HasDuration or Infinite, you gain access to the Duration Magnitude field.

For a HasDuration policy, you can define the time using a ScalableFloat:

// Example of configuring a Duration Effect in code
DurationMagnitude = FScalableFloat(10.0f); // Sets the effect to last 10 seconds
DurationPolicy = EGameplayEffectDurationType::HasDuration;

When you apply these via ApplyGameplayEffectToTarget, the ASC handles the math. An Instant effect will modify the base value directly, while Duration and Infinite effects are added to the active container, allowing the ASC to calculate the "net" attribute value by summing the active modifiers alongside the base value.

Key Takeaway: Use Instant for one-off events, Duration for time-limited buffs, and Infinite for permanent state changes that require manual removal.