Appearance
Ability Sample
This walkthrough examines the framework's SprintAbility as implemented in the Compact Multiplayer Showcase.
The complete loop
- The ability is granted to
ShowcaseCharacter. AbilityInputSettingsbinds it to the sprint network input.CanActivaterequires positive Stamina after base policies pass.Activateadds a movement speed bonus ofspeedMultiplier - 1.- Every Fusion tick removes Stamina through
AbilitySystemComponent.ApplyModifier. - Releasing input, interruption, or reaching zero Stamina exits the loop.
finallyremoves the speed bonus.
Cleanup must cover every exit path. The finally block restores temporary movement state whether input is released, execution is interrupted, or the ability ends for another reason.
csharp
while (!coroutine.Interrupted &&
coroutine.AbilitySystem.IsInputPressed(InputSettings.Input) &&
coroutine.AbilitySystem.GetCurrentValue(staminaAttribute) > 0f)
{
if (characterController.MovementIntent.sqrMagnitude > 0.0001f)
coroutine.AbilitySystem.ApplyModifier(staminaAttribute, ModifierOperation.Additive,
-staminaPerSecond * coroutine.AbilitySystem.Runner.DeltaTime);
yield return new AbilityWaitTicks(1);
}Compare it with Jump, which has a fixed action and cooldown, and with weapon fire and reload, which resolve the currently equipped Weapon. Consult Manual: Abilities before implementing a new ability.