I changed the healing to check for the difference between max and current health first, rather than lowering the currenthp to max if it exceeds, so avoid any issues.
public void RestoreHealth(float amount)
{
if (currentHealth < characterData.MaxHealth)
{
// if the amount healed would exceed max health, heal to full instead
if (amount > (characterData.MaxHealth - currentHealth))
{
currentHealth = characterData.MaxHealth;
}
// otherwise, just gain the health
else
{
currentHealth += amount;
}
}
}
This works because Mathf.Min() always picks the smaller value, so if your character’s health exceeds the max health, then the max health value will be used instead.
Poor farming practices and policies across the world have led to the degradation of agricultural soils in the world. This has led to the loss of nutritional value in our food over the years, and it will affect our food production capabilities in the coming decades.