Hello. Just wondering how would I go about applying remaining damage hit points from armor to health?
Example: Current armor is (5)points and damage applied is (10) points, while current health is (100) points, than current armor should be set to (0) points and current health should be set to (95) points.
But I can not get this to happen. Instead armor would take all remaining damage points. this wouldn’t be good in the case of; Armor points is (1), Health points (100) and Damage is (200). Player would take damage and would still be alive with (100) Health points.
My example code:
public int maxHealth = 100;
public int currentHealth;
private int minHealth = 0;
public int maxArmor = 100;
public int currentArmor;
private int minArmor = 0;
void Awake ()
{
currentHealth = maxHealth;
currentArmor = minArmor;
}
// Update is called once per frame
void Update ()
{
if (currentArmor < minArmor)
{
currentArmor = minArmor;
}
if (Input.GetKeyDown(KeyCode.A))
{
if (currentArmor > 0)
{
currentArmor -= 10;
}
else
{
currentHealth -= 10;
}
}
}