Way to set max health?

hey guys back again with a probably stupid question, i followed a tutorial to add a damage system to the game, works great but i am attempting to add a pickup to add health, is there a way to max out the health to 100 at the moment my pickup gives you 40 health so if you pick it up at 100 it’ll put you at 150, i would like it to not pick up when full and if not full give a max of 100

You need to check the player’s health first before making the logic of picking up a medkit.
Use branch node to compare current player’s health with maximal health. If it is equal/more to the maximal health just do nothing.

PS: To make programming easier - write down the logic that you want to make, it helps a lot but be careful with the order of things.

so how would i set minimum and max health to check?

Create a new variable, call it MaxHealth. Configure it as appropriate on your main blueprint class instance (defaults.)

When attempting to add health, do something like:

“Health = Min(Health + Added, MaxHealth)”

You might also want to not consume the healthpack, if your Health is already >= MaxHealth.

1 Like