Section 11: Lecture 146: Comparing by Health Percentage

It kinda bothered me that regardless of how well the player was doing including avoiding damage or a situation where the player uses a healing item only to level at full health and lose 30% of their health as a sort of leveling tax. So I decided that a method that looks at the percentage of health the player currently has and compares it to the base health regeneration and which ever of the two is higher becomes the value the maximum health gets multiplied by.

Here’s my code snip it if you’re curious.

void RegenerateHealth()

        {

            float checkHealth = currentHealth/maxHealth;

           

            maxHealth = baseStats.GetStat(Stat.HEALTH);

            float regenRate = Mathf.Max(baseHealthRegen, checkHealth);

           

            currentHealth = Mathf.Round(maxHealth*regenRate);

        }

An equitable solution. Of course, technically, the player isn’t losing any health at all, it just looks that way.

Some students (actually I do this too) simply let the player’s currentHealth = maxHealth upon levelling up. I like to call it “Second Wind”.

2 Likes

Yeah I guess it’s more of what feels better, more than anything.

Like if I made an object that gave the player a buff to their stats based on the percentage of health they had all the sudden when they level up they lose 30% of that bonus regardless of how much damage they’ve taken, that wouldn’t feel particularly good as a player.

The set to maximum method does seem more typical in this type of game however, I might switch over to that system depending on how it feels later.

Privacy & Terms