UnityGameProjectsCode / InTheDarkGame / Level / DrainPlayerHealth.cs
DrainPlayerHealth.cs
Raw
using UnityEngine;

public class DrainPlayerHealth : MonoBehaviour
{
    public float damageAmt;

    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            collision.gameObject.GetComponent<Health>().ModifyCurrentHealth(damageAmt);
        }
    }
}