(The player casting a Fireball)
Mana Regeneration
To regenerate mana over time is as easy as creating a Trigger that invokes an Actions object as soon as the game starts. These Actions are:
Increase the Mana attribute by 5
Wait 0.1 seconds
Restart the Actions object
This sequence will ensure that every 0.1 seconds, the player’s mana attribute will increase by a small portion.
Fireball Spell
To cast the Fireball we first need to know if there is enough mana in the player’s gauge. To do so, we simply use a Trigger that detects when the user has pressed the Left Mouse button. As soon as that happens it invokes an Event which checks if there’s enough mana to cast the spell.
Then, to actually cast the spell we use the Instantiate Action, which creates an instance of a prefab we have previously designated as the Fireball.
(Fireball cast Event)