using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HealthDelta : MonoBehaviour
{
    public LayerMask affects;
    public float delta;

    private void OnCollisionEnter(Collision other)
    {
        if (((1 << other.gameObject.layer) & affects.value) != 0 && other.gameObject.GetComponent<Health>()) {
            other.gameObject.GetComponent<Health>().ChangeHealth(delta);
        }
    }

    private void OnTriggerEnter(Collider other) {
        if (this.gameObject.layer != other.gameObject.layer && other.gameObject.GetComponent<Health>()) {
            other.gameObject.GetComponent<Health>().ChangeHealth(delta);
        }
    }
}
