[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.

You could do something like, Player Picks Up Healing Item > Start Looping Timer > Every 1 sec (example) Add (Amount) to health and at the same time check if Current Health >= Max Health, if true, set Current Health to Max Health (so you can’t go over max health) and clear and invalidate the timer. This could be used if you wanted the healing item to always heal player up to max health.

If you wanted it to only heal a certain amount over time, then just have it check against that amount at the same time when checking if Current Health >= Max Health, and just invalidate the timer once it’s reaches its healing limit.

Is this for an item that is picked up or a stationery item? I need it to stay available, it’s a health geyser.

You could tailor it to any. You could just use On Being Overlap to start the timer to add health, and On End Overlap to stop the timer. Just ensure you have a check when adding health that if Current Health >= Max Health, Set Current Health to Max Health, this way no matter how long you are overlapping, your health will never go above max.