Skip to content

Instantly share code, notes, and snippets.

@Stektpotet
Last active December 19, 2017 19:08
Show Gist options
  • Save Stektpotet/6cdb2bf755187bb8cc916f7f54e5c6cc to your computer and use it in GitHub Desktop.
Save Stektpotet/6cdb2bf755187bb8cc916f7f54e5c6cc to your computer and use it in GitHub Desktop.
using System;
using UnityEngine;
using UnityEngine.Events;
namespace HumanAPI
{
[RequireComponent(typeof(Collider))]
public class Trigger : MonoBehaviour
{
public LayerMask activatorLayers;
public UnityEvent onEnter, onStay, onExit; //
private void OnTriggerEnter(Collider other)
{
if ((activatorLayers & 1 << other.gameObject.layer) > 0)
onEnter.Invoke();
}
private void OnTriggerStay(Collider other)
{
if ((activatorLayers & 1 << other.gameObject.layer) > 0)
onStay.Invoke();
}
private void OnTriggerExit(Collider other)
{
if ((activatorLayers & 1 << other.gameObject.layer) > 0)
onExit.Invoke();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment