rabidus-test/Assets/Scripts/TriggerZone.cs

37 lines
683 B
C#
Raw Permalink Normal View History

2023-07-24 16:38:13 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerZone : MonoBehaviour
{
protected ShipPathFollower _ship;
2023-07-24 16:38:13 +03:00
protected void OnTriggerEnter(Collider other)
{
if (other.gameObject.TryGetComponent(out ShipPathFollower ship))
2023-07-24 16:38:13 +03:00
{
_ship = ship;
InZone();
}
}
protected void OnTriggerExit(Collider other)
{
if (_ship != null)
{
OutZone();
_ship = null;
}
}
protected virtual void InZone()
{
Debug.Log("InZone");
}
protected virtual void OutZone()
{
Debug.Log("OutZone");
}
}