MaxHealth display, not really a bug but

Hi Brian.

What I notice just now, is that the health/maxhealth display did not match at the beginning of my game.

Why ? Because the heathPoint (in DisplayHealth of EnemyDisplayHealth) is coming from the “variant prefab” (or the character in the inspector) of the different characters (Health, public float GetHealthPoints() { return healthPoints; }) and the MaxHealthPoints is coming from the BaseStats (Health, public float GetMaxHealthPoints() { return GetComponent().GetStat(Stat.Health); }.
If at the beginning we check if the health is set to something (not the default -1)
Health, Start,
if (healthPoints < 0.0f)
{
healthPoints = GetComponent().GetStat(Stat.Health);
}
We dodn’t check if the healthPoints at the beginning of the game (not the saved one) is equal to the BaseStat healthPoints. So the two values could be different.

So… be sure that the health value of a given character matches the “progression” value for its class.
Of maybe some kind of check at the first launch.

M. D.

Later in the last section of the course, we’ll be introducing a new class LazyValue that will solve the race condition issues you’re describing.

OK, great, thank you Brian.

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

Privacy & Terms