Author Topic: Increasing Mana over time [SOLVED]  (Read 1853 times)

3D Lunatic

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Increasing Mana over time [SOLVED]
« on: October 31, 2019, 10:39:13 AM »
I did a search on this topic, but the answers gave a method for uninterrupted increase. They recommended HOTween.

What I have is a mana bar (magical energy). Whenever the character uses a magical ability, some mana is subtracted from the bar. Over time, the mana should automatically refill, let's say at a rate of 1 point per second. I have maximum mana set to 100, just for sake of ease.

How can I set up the automatic refilling of mana in my ManaManager? Currently, I created an FSM which checks if the mana is at max, and if not then it goes into a state called "Increase Energy". But I'm at a loss as to how I should increase mana here. I want the flexibility to change the rate of increase (when the player trains, they can increase the rate of mana recharge). Also, I don't think I should be tweening mana, because the player can discharge some mana even if it's not full. If I do a tween, the mana will continue to rise until the tween is completed, regardless of whether the player is using mana during that time.

Any suggestions? Thanks in advance.
« Last Edit: November 01, 2019, 01:36:10 AM by 3D Lunatic »


  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Increasing Mana over time
« Reply #1 on: October 31, 2019, 04:03:44 PM »

So If I'm reading this correctly, you want the mana regen to stop for a few seconds after being used before it starts again?  And the regen part should be flexible?

If so then thats easy to set up.  Have state 1 listen for a mana usage event and also a wait action event.  If mana is use, it enters state 2 that has a wait action event and a mana usage event.  If mana is use again while in state 2, it re-enters state 2 to reset the wait timer.  If the wait timer goes off in either state 1 or 2 then enter state 3 which is mana regen.

State 3 simple first checks if mana is full, if it is, fire off into state 1 again otherwise add X mana.  Adding mana can just be a simple equation (CurrentMana + X = CurrentMana) or more complex depending on how you want to approach it (CurrentMana+ (X + multipliers + bonuses) = CurrentMana.

Let me know if that helps. 



  • Administrator
  • Hero Member
  • *****
  • Posts: 15396
  • Official Playmaker Support
    • View Profile
Re: Increasing Mana over time
« Reply #2 on: November 01, 2019, 01:27:43 AM »

 in your "Increase Energy" state use the action FloatAdd, and check "everyframe" and "per seconds", then your done, no need for complex tweening or anything.



3D Lunatic

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: Increasing Mana over time [SOLVED]
« Reply #3 on: November 01, 2019, 01:36:31 AM »
Thank you!