How-To: Make a Cast-Time Ability
Goal: build an ability that shows a cast bar, then delivers its effect when the cast finishes - using UCrimsonGameplayAbility_WithCastTime.
Prerequisites
Quick Start complete. You know which input tag will trigger the ability.
1. Subclass the cast-time ability
Screenshot pending
Images/CrimsonAbilitySystem/howto-casttime-subclass.pngImplement the cast lifecycle events in the event graph: K2_OnCastStarted, K2_OnCastCompleted, K2_OnCastInterrupted.
| Event | When called |
|---|---|
K2_OnCastStarted(TotalCastTime) | Cast timer begins - start the montage / UI bar |
K2_OnCastCompleted() | Cast finished without interruption - deliver the effect here |
K2_OnCastInterrupted() | Cancelled, or the pawn moved past the threshold |
2. Configure cancellation and commit timing
- Set
bCancelOnMovement = trueandMovementCancelThreshold(cm) to auto-interrupt when the caster moves. - Set
CommitTimetoOnCastCompletedso a cancelled cast costs nothing (no cooldown, no resource spend). - Override
GetCastSpeedModifier()in your game subclass to scale cast time from an attribute (returns1.0by default).
Verify
Activate the ability in PIE: the cast bar plays, moving cancels it (if enabled), and the effect only lands on completion. A cancelled cast applies no cooldown when
CommitTime = OnCastCompleted.See also
- Concept: Gameplay Ability - activation policy, commit time, costs
- Concept: Ability Contract - where
CastTimecomes from