rabidus-test/Assets/Scripts/CheckPoint.cs

35 lines
708 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
public class CheckPoint : MonoBehaviour
{
public UnityEvent OnCheckpointPass;
private SplineTrigger _splineTrigger;
[ContextMenu("Debug Checkpoint")]
public void CheckPointPass()
{
OnCheckpointPass?.Invoke();
}
private void Awake()
{
_splineTrigger = GetComponentInChildren<SplineTrigger>();
}
private void OnEnable()
{
_splineTrigger.OnTriggerEvent.AddListener(CheckPointPass);
}
private void OnDisable()
{
_splineTrigger.OnTriggerEvent.RemoveListener(CheckPointPass);
}
}