Health Update

This commit is contained in:
Sebastien 2015-12-04 13:01:12 -05:00
parent 79da09f3da
commit 5419a9b62a
13 changed files with 13 additions and 7 deletions

Binary file not shown.

View File

@ -29,9 +29,12 @@ public class PlayerHealth : MonoBehaviour
playerAudio = GetComponent <AudioSource> ();
playerController = GetComponent <PlayerController> ();
//playerShooting = GetComponentInChildren <PlayerShooting> ();
healthSlider = GameObject.FindGameObjectWithTag("HealthSlider").GetComponent<Slider>();
// Set the initial health of the player.
currentHealth = startingHealth;
}
@ -42,14 +45,17 @@ public class PlayerHealth : MonoBehaviour
}
void OnTriggerEnter(Collider other)
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("HealthPickup"))
{
Debug.Log("Health Pickup");
currentHealth = currentHealth + healthToRecoverOnPickup;
if (currentHealth > startingHealth)
{
currentHealth = startingHealth;
}
healthSlider.value = currentHealth;
Destroy(other);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB