mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 01:21:07 +00:00
29 lines
473 B
C#
29 lines
473 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);
|
|
health.text = "Health: " + other.gameObject.GetComponent<Health>().addHP(3);
|
|
|
|
|
|
// Destroy the crate.
|
|
Destroy(gameObject);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|