You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
792 B
33 lines
792 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
public class RangeDetection : MonoBehaviour
|
|
{
|
|
public UnityEvent EnterRange;
|
|
public UnityEvent OutRange;
|
|
public string triggerTag;
|
|
|
|
private void Start()
|
|
{
|
|
if (triggerTag != "") return;
|
|
triggerTag = "Player";
|
|
}
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (GameManager.GetInstance().IsStartEvent) return;
|
|
if (other.gameObject.tag==triggerTag) {
|
|
EnterRange.Invoke();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (GameManager.GetInstance().IsStartEvent) return;
|
|
if (other.gameObject.tag == triggerTag)
|
|
{
|
|
OutRange.Invoke();
|
|
}
|
|
}
|
|
}
|