35 lines
922 B
C#
35 lines
922 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TriggerZone : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Triggerable linkedObj;
|
|
[SerializeField]
|
|
private bool onEnter = true, onStay = false, OnExit = false;
|
|
// Start is called before the first frame update
|
|
private void OnTriggerEnter(Collider other) {
|
|
Debug.Log("Enter");
|
|
if(!onEnter)return;
|
|
if(other.gameObject.tag.Equals("Player")){
|
|
linkedObj.TriggerEvent();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerStay(Collider other) {
|
|
if(!onStay)return;
|
|
if(other.gameObject.tag.Equals("Player")){
|
|
linkedObj.TriggerEvent();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other) {
|
|
Debug.Log("Exit");
|
|
if(!OnExit)return;
|
|
if(other.gameObject.tag.Equals("Player")){
|
|
linkedObj.TriggerEvent();
|
|
}
|
|
}
|
|
}
|