mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 09:31:07 +00:00
28 lines
482 B
C#
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);
|
|
|
|
}
|
|
|
|
}
|
|
}
|