How to make potion that heals over time?

I want design a potion that give “heal 200 over time for 5 seconds(in 5 seconds will heals totally 200 hp)”
so how should I draw blueprint?

so,no one else known about this? or can I have some reference?

Here is a possibility:


You could make a simple event that regenerates player’s health using a timer. For something very simple it might just be enough.

But there is a better, more modular method that does not limit you to having a single effect affecting the player (or any other entity for that matter). Think of it as of a temporary effect (or an ability) that the player gains for X amount of time and once the time is up, the effect expires. And more of those can be active at the same time, too. So imbibing a couple of healing potion while standing in a pool of lava (which could be just another effect) is quite easily doable.

Create an actor component that will serve as a healing effect, you will need to expose some variables:

In this case we’re going to heal 200 points of player’s health over 5s and we’ll be adding health every .1s

Setting Heal Frequency to 1 will boost the player by 40 health every 1 seconds but still by a total of 200 points over 5s. Setting Heal Frequency to 0.1, will heal the player 10x a second, yet they will only gain 200 points over 5s anyway. This variable dictates how often an effect is applied but does not affect the total amount or time. You just need to ensure that *Over Time *can be cleanly divided by *Heal Frequency *or improve the math below.

And the component looks like this:


As soon as the component is given to the player, it starts its own internal timer which adds a specific amount of health to the player’s existing health variable. Once it has *Healed So Far *enough, it destroys itself.

This is a just a stub of a system rather than a deploy-ready solution. I tested it *very *briefly here and it seemed to do what it says on the tin. There’s no exception handling of any sort at the moment so you may want to add that (like accidental zero division, for example :slight_smile:

I’ve been using something similar (with extra features) to drain / boost attributes of various in-game entities and it has served this purpose well. Needs modifying if you need it to work with something else than a player, of course. Again, just a stub but can be fleshed out nicely.

edit: forgot to add - the use scenario would be that a Potion Actor, when used, would spawn the above-mentioned component effect, propagate the necessary attributes and make the player the component’s owner.

thank you , I’ll try it