Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: 3D Lunatic on October 31, 2019, 01:39:13 PM

Title: Increasing Mana over time [SOLVED]
Post by: 3D Lunatic on October 31, 2019, 01:39:13 PM
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.
Title: Re: Increasing Mana over time
Post by: Athin on October 31, 2019, 07:03:44 PM
Heya,

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. 

Thanks
Title: Re: Increasing Mana over time
Post by: jeanfabre on November 01, 2019, 04:27:43 AM
Hi,

 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.

Bye,

 Jean
Title: Re: Increasing Mana over time [SOLVED]
Post by: 3D Lunatic on November 01, 2019, 04:36:31 AM
Thank you!