SE_JonF
(SE_JonF)
May 31, 2016, 3:20pm
5
You dont have to use float at all.
Floats give a bit more flexibility in every kind of calculation but it depends on what you want to achieve.
Do you need the regeneration to be as precise as possible? ( = every frame) or just some health after a while?
Single or multiplayer based?
I love to use Timers for regeneration and for that you could also use integers.
Singleplayer for the moment, but possibly multi in the future. I’m trying to setup a system that regenerates health say 5 seconds after you’ve last taken damage. I was able to get the regeneration to work, but the delay value seems to repeat. (i.e. 5 seconds, +5 health, 5 seconds + 5 health). I tried the retriggerable but that doesn’t seem to work at all.
You can create a system to repeatedly call a function to increase your health.
Create a function, I’d call it StartRegen;
Create a boolean bIsRegenerating?;
Inside your StartRegen function, make a branch to check if you bIsRegenerating is true. After that, increase your health by ‘1’. And after that, use the node “Set Timer by Function Name”. The Function Name will be StartRegen and the time you decide.
Following this logic, you can get close to an analog health regeneration (using int) depending on the time you set inside Set Timer by Function Name. It’s a good way to control how much health you want the player to regen in a period of time. It has, too, condition to stop regenerating since you set the bIsRegenerating to false, it will not execute the loop again. You can add that it stops regenerating when the health is set to maximum value and it interrupts the call loop, too…
I tried doing this, but I couldn’t seem to get it to work. I should probably note I’m very new to blueprints.
Floats are nice to have and use, but are not required for an operating health system. Depending on the type of regen system you have in mind, your mileage may vary.
I personally put the regen system into a Function. I put all of the handling of the regeneration into the function, including the checks and balances of whether we have exceeded or even if we can regenerate. All of this is figured out before any regeneration is even done. I will leave it up to you on how you wish to accomplish this, and if you are following tutorials, it is really easy to adapt the system to Integers.
When setting up all of the stats and stuff, put a Set Timer by Function and put the function name in. Turn on the Looping and give it a delay as you see fit, I personally use a variable so that it is unique to that instance of the blueprint. The nifty thing about that variable I just made, it is a Float variable. This is where you can implement the Float part of the tutorial if you deem it necessary.
I’ll give that a try. This stuff gets confusing pretty fast. I’m surprised there isn’t a whole lot of coverage on how to setup extensive health systems (health, shields, regen, etc.).