Increasing Max Health Issues (4.15) (SOLVED)

crazygrouptrio

Active member
My game has a max health system that works fine, until the player dies and then it defaults the players health to what the health is set to in its object details, and assumes this is the player's max health.
So this is how it plays out: Player health in object details is set to 30. When player's health is increased to 60, it all works correctly until the player dies, and when he respawns his health is set to 30, and will not go up from health pickups because it thinks the max health is 30.. until the player takes damage, which fixes the system and then health can go up to 60. Obviously this is not ideal.

For the life of me I cannot find where this is handled in 4.15. I just need the player's health to always be determined on my maxhealth variable, and it does except in this one instance. Any help would be appreciated thanks!
 

Jonny

Well-known member
I don't have 4.1 but I'd say look for the max health variable in something like 'handle player hurt' or something along those lines. Look in your script setting to see what it's actually called for 4.1
Whatever is being done to store the max health in that script needs to happen in your health pickup too. That's how I'd approach it anyway.
 

crazygrouptrio

Active member
I don't have 4.1 but I'd say look for the max health variable in something like 'handle player hurt' or something along those lines. Look in your script setting to see what it's actually called for 4.1
Whatever is being done to store the max health in that script needs to happen in your health pickup too. That's how I'd approach it anyway.
Yep, I've done that. The max health variable works 100% fine in actual gameplay. It's only when the player respawns that it ignores this variable and defaults to the player's health set in object info, and it then assumes this is the max until the player gets hurt and it corrects itself to the actual max health variable. (I know its confusing) I imagine player health from the object info is being assigned somewhere deeper that I can't find, OR there's a way around it I also can't figure out.
 

crazygrouptrio

Active member
Well everything is done in increments of 5. (Player takes 5/10/15 dmg etc). As it is now, the player starts with 30, then gets a health upgrade to 60, and its fine until the player dies, then it's stuck at 30 until the player takes damage, then it accepts health pickups to 60 again. I've tried changing what the initial health of the player is in object info, and when the player dies it always defaults to that amount. If I set it to 5, the player will have 5 health when he respawns, or if I set it to 200 the player has 200 when they respawn. So I've narrowed down the problem, I just can't find where it's handled..
 

crazygrouptrio

Active member
For anyone who has a similar problem, I did a really stupid workaround that works fine. Whenever the player dies they respawn on the last checkpoint tile, so I just had the checkpoint tile fill the players health. Doesn't fix the problem but it does work.
 

Jonny

Well-known member
Did you try adding some code to the health pickup? To save the max health at that point.

I guess if the workaround works tho.
 

crazygrouptrio

Active member
Did you try adding some code to the health pickup? To save the max health at that point.

I guess if the workaround works tho.
Yeah its not that. It's specifically the part of the script that sets the player's health when the player is created (wherever that may be). So this workaround basically fixes it by resetting the health after the player is created.
 
Top Bottom