MIF_E31222398/Assets/Script/HealthPickUp.cs

26 lines
516 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthPickUp : MonoBehaviour
{
public int healthRestored = 10;
// Start is called before the first frame update
void Start()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Damageable damageable = collision.GetComponent<Damageable>();
if (damageable)
{
damageable.Heal(healthRestored);
Destroy(gameObject);
}
}
}