rabidus-test/Assets/SplineTrigger.cs

28 lines
589 B
C#
Raw Normal View History

2023-08-15 17:38:54 +03:00
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();
}
}
}