Last active
December 19, 2017 19:08
-
-
Save Stektpotet/6cdb2bf755187bb8cc916f7f54e5c6cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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