Player loses health after leveling up

Why does the player loses health after leveling up? Will this be fixed in upcoming tutorials?

The player doesn’t ‘lose’ health. The maximum health increases, so the difference between 8/10 health is less than 8/15 health. With 8/10 the player is at 80% health, but with 8/15 the player is at ~53% health. The health is still 8.

If I recall correctly, Sam does mention something about this somewhere in the course and offers up the choice to reset the player’s health to max when they level up. But I can’t remember if I’m just imagining this

Thanks for the answer @bixarrio
Yes, Sam mentions something about this. However, at this point, if you kill an enemy with a ranged weapon (arrow or fireball), and thus don’t engage in melee so you don’t get hit by an enemy, and level up, it is weird to have your health decreased. Do you know what I mean?
I hope that this gets fixed somewhere later in the course.

Being an OG World of Warcraft player from back in the day, I tend to like the “Saved By Levelling up” effect… This is where you’re in a big nasty battle with several baddies, and you are on the brink of death, just a couple hit points left when you kill a baddie and level up and BEWM 100% Health and Mana.

The “loss” of health with the way Sam has the code is an illusion, you really are gaining health, but since it’s not setting to max-health, it will always look like you lost health on a percentage bar. If you put a text component on top of the health Bar showing the current health points and the max health points (like 50/75, for example), that helps untrick the mind’s perception that you lost health.

Alternatively, you can grant the player the full health he deserves by simply setting currentHealth to the new Max Health on Levelling up.

1 Like

Personally, I like to increase both max and current health, so if my new level adds 5hp to my max, I add the 5hp to my current as well. If I was on 8/10, I will be on 13/15 after level up, and still only 2hp down. But I guess it depends on personal preference and what the game calls for

@Brian_Trotter @bixarrio
Thanks a lot for the answers

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms