28 lines
589 B
C#
28 lines
589 B
C#
|
using Dreamteck.Splines;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Events;
|
||
|
|
||
|
public class SplineTrigger : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField]
|
||
|
private LayerMask _layerMask;
|
||
|
|
||
|
private bool _triggerOnce = false;
|
||
|
|
||
|
public UnityEvent OnTriggerEvent;
|
||
|
|
||
|
private void OnTriggerEnter(Collider other)
|
||
|
{
|
||
|
if (_triggerOnce)
|
||
|
return;
|
||
|
|
||
|
if ((_layerMask.value & (1 << other.transform.gameObject.layer)) > 0)
|
||
|
{
|
||
|
_triggerOnce = true;
|
||
|
OnTriggerEvent?.Invoke();
|
||
|
}
|
||
|
}
|
||
|
}
|