Created
October 28, 2017 22:05
-
-
Save JonathanYin/8b433edc3fbdd3fe8b8939c22e2245b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.UI; | |
public class HealthBoost : MonoBehaviour | |
{ | |
//public Animator anim; | |
public GameObject player; | |
public GameObject healthItem; | |
public PlayerHealth ph; | |
public Slider hs; | |
void OnTriggerEnter (Collider other) | |
{ | |
if(other.tag == "Player") | |
{ | |
if (ph.currentHealth > 50) { | |
ph.currentHealth = 100; | |
hs.value = ph.currentHealth; | |
} | |
else | |
{ | |
ph.currentHealth += 50; | |
hs.value = ph.currentHealth; | |
} | |
Destroy (healthItem); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment