Attack with Cooldown
Use this graph when an attack request should enter the Attack state only after a shared cooldown is ready.
In the editor
- Create a float Shared Variable named Next Attack Time.
- Add a standalone Idle state named Ready and an Action State named Attack. Idle remains Running while it waits for a request; it is a state node, not an entry in an Action State’s Action list.
- Connect Ready to Attack. Remove the default State Finished Condition, then add the input, target, or range Condition that requests the attack and Cooldown Ready. Assign Next Attack Time to Cooldown Ready.
- Set the Ready-to-Attack transition’s Condition Mode to All and Evaluation Mode to Continuous.
- In Attack, add the project-specific attack Actions and Start Cooldown. Assign Next Attack Time to the Action and set the desired Duration.
- Connect Attack back to Ready with State Finished.
Both Start Cooldown and Cooldown Ready must reference the same Shared Variable and make the same scaled-versus-unscaled-time choice.
How it runs
Ready accepts an attack request only when the current time has reached Next Attack Time. Attack performs its Actions, stores a new ready timestamp through Start Cooldown, and returns to Ready when the state finishes. Further requests cannot take the Ready-to-Attack transition until Cooldown Ready becomes valid.
Put Start Cooldown before the attack Actions when the delay should begin as soon as Attack starts. Put it after those Actions when the full delay should begin after the animation or ability completes.
Key choices
- Keep Reset On State Machine Start enabled when a newly started graph should attack immediately. Disable it when the timestamp must survive a pause, restore, or another owner of the same variable.
- Wait on Start Cooldown delays the Action when a cooldown is already active, Restart starts a fresh duration, and Finish Without Restart preserves the active timestamp.
- Use unscaled time for UI or pause-independent abilities; otherwise keep both nodes on scaled time.
- Store separate ready-time variables for abilities that have independent cooldowns.
Verify in Play Mode
Request the attack repeatedly. Confirm that Attack becomes active once, returns to Ready, and cannot reactivate until the configured duration has elapsed. Inspect Next Attack Time to confirm that Start Cooldown updates the same value read by Cooldown Ready.