[PAPER2D] Complex Healing Items

Attention, Traveller,
I am making a 2d platformer and I am very stumped at one issue. How do I make an Item that will heal the character over time, but not exceed the full health limit? So far I have made:

  • An item that does damage over time

  • An item that heals over time and does stop at the player’s max health, but it continues to heal even after the character is no longer overlapping

  • And an item that does the same as the previous item, but doesn’t stop at the player’s maximum health

    What am I doing wrong and what do I have to do to get it right? Also, sorry if that opener was too geeky, haha.

I’m not sure how you’re ticking the healing effect but it would seem that you should add the current health to the increment value and check to see if it’s greater than the player’s max health. If it is, set the health to be the player’s max health (and possibly end the effect? Not sure how your item should behave). If it’s not, increment and keep ticking.