How do I add a cooldown for a spell?

Is there any way i can add a cool down to my spell? I want it to be that when he clicks 1 it will fire the spell then pt it on a cool down. How can i do this?

Hey -

You could add a branch check to see if a bool variable (isCooldown) is true before casting the spell. If it is true the the spell won’t cast, if it is not true then you can cast the spell. After casting the spell set the variable to true. Then on Tick you can test if isCooldown is true and if so, set a delay for how long you want the cooldown to be, then set it to false.

Cheers

You can use timers:
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/index.html

In simple algorithm it will be:

Add two variables into blueprint/code (isCasted - bool and Cooldown - int) and then

  • Cast event (button/AI/etc)
  • Branch node (or if) where you check your isCasted variable
  • If spell not casted (isCasted = false) then you do usual casting actions and set isCasted to true, then start Timer on Cooldown time
  • In Timer ‘loop’ just reset isCasted variable to true value on complete.
  • And then if you try to cast spell when isCasted = true, you go to another branch of Branch node where you can add info message (or do nothing)