Skip to content

Instantly share code, notes, and snippets.

@JonathanYin
Created October 28, 2017 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanYin/8b433edc3fbdd3fe8b8939c22e2245b5 to your computer and use it in GitHub Desktop.
Save JonathanYin/8b433edc3fbdd3fe8b8939c22e2245b5 to your computer and use it in GitHub Desktop.
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