How-To: Use Toggle, Charges and Channeling
Goal: pick the right shipped ability shape instead of re-implementing it.
Toggle
UCrimsonGameplayAbility_Toggle stays active until the input is pressed again. Use it for stances, auras and sustained modes. Its buff effect, its recurring costs and its tick abilities all come from the contract - see How-To: Set Up a Toggle Ability for the full walkthrough.
InputPressed and InputReleased only fire on the locally controlled client, so an override cannot tell the server the toggle went off. UCrimsonGameplayAbility_Toggle listens with a replicated UAbilityTask_WaitInputPress instead: the client RPCs the press through the ability-task pipeline and the server ends the ability itself. Copy that pattern in any hand-rolled ability that stays active across presses.| Event | Runs on | Use for |
|---|---|---|
On Toggled On (Cosmetic), On Toggled Off (Cosmetic) | Server and predicting client | VFX, sound, UI state. |
On Toggled On (Authority), On Toggled Off (Authority) | Server only | Spawn actors, apply gameplay effects. |
Cost Gameplay Effect Class is committed on activation. The cooldown is not tied to that: Cooldown Policy chooses whether it starts when the toggle turns on, when it turns off, at both ends, or only when you call Trigger Toggle Cooldown. The recurring drain is the contract's Periodic Costs, each on its own interval; if one becomes unaffordable at its own moment the toggle ends.Charges
UCrimsonGameplayAbility_Charges holds N uses that refill over time. Read state with Get Max Charges and Get Current Charges; activation fails with Ability.ActivateFail.Charge.OutOfCharges when empty.
Bind a UI widget to Get Current Charges and listen for Ability.ActivateFail.Charge.OutOfCharges to flash the button.
ChargesUsed is mutated only on the server and sent to the owning client by a reliable RPC, so Get Current Charges updates about half a round trip after the press. Bind UI to the OnChargesChanged delegate rather than reading the count immediately after activating.Channeling
UCrimsonGameplayAbility_Channeling ticks at an interval while held and can break on movement.
| Function | Does |
|---|---|
| Start Channeling / Stop Channeling | Begin and end the channel explicitly. |
| Set Channel Tick Interval | How often the channel ticks. |
| Set Max Channel Time | Hard cap on the channel duration. |
| Set Cancel On Movement | Break the channel if the avatar moves. |
The tick heartbeat runs on both machines. Per-tick gameplay belongs in the authority event.
| Event | Runs on | Use for |
|---|---|---|
On Channeling Started (Cosmetic), On Channeling Tick (Cosmetic), On Channeling Stopped (Cosmetic) | Server and predicting client | Beam VFX, sound, UI. |
On Channeling Started (Authority), On Channeling Tick (Authority), On Channeling Stopped (Authority) | Server only | Damage ticks, spawning, resource drain. |
Channeling Input Type = Hold waits on UAbilityTask_WaitInputRelease; Toggle waits on UAbilityTask_WaitInputPress. Both replicate to the server, so the server ends the channel on its own rather than being told to by the client. Cancel On Movement is likewise evaluated only on the server.Ability.State.Channeling is removed.See also
- How-To: Set Up a Toggle Ability
- How-To: Make a Cast-Time Ability
- Concept: Ability Subclasses