In this lecture, we made a variable regenerationPercentage to provide a minimum health percentage to regenerate upon leveling up. I was interested in how to set this minimum value based on the health percent remaining at level up, so I did the following steps.
Added a new public event Action beforeLevelUp
Placed the call to this right before the currentLevel = newLevel in the UpdateLevel method
Subscribed with a “CarryoverHealth” method in Health.cs
The method contains
regenerationPercentage = GetPercentage();
Upon leveling up, there’s a quick (?) call to set the regenerationPercentage for the Health script, which is then used as the minimum health value in the RegenerateHealth method. Now, if my character is at 30% when leveling, it only regenerates to 30% after the level up.
Was this the right solution?