I took a slightly different approach. I give the player the same amount of health increase by the amount they already had. I also give the player a helping hand if they have a loss of health they get an extra increase.
Player has 100% health they level up the regen is only 75% the player still has 100% health.
Player takes a beating and is at 5% health they Level up they get a health increase of 75%
[SerializeField, Range(0, 1)] private float healthRegenOnLevelUpPercent = .75f;
public float Max { get; private set; }
private void Start()
{
Max = _baseStats.GetStatValue(Stat.Health);
}
public float GetPercentage()
{
return IsDead ? 0 : value / Max;
}
private void RegenerateHealth()
{
float currentPercentage = GetPercentage();
Max = _baseStats.GetStatValue(Stat.Health);
value = Mathf.Max(Max * currentPercentage, Max * healthRegenOnLevelUpPercent);
}