Labo_2_equ_2_a15/Assets/Scripts/HealthPickup.cs
2015-11-30 18:25:48 -05:00

28 lines
482 B
C#

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class HealthPickup : MonoBehaviour
{
public AudioClip audioPickup;
public Text health;
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
AudioSource.PlayClipAtPoint(audioPickup, transform.position);
// Destroy the crate.
Destroy(gameObject);
//heal player
health.text = "Health: " + gameObject.GetComponent<Health>().addHP(3);
}
}
}