rabidus-test/Assets/Scripts/TriggerZone.cs

38 lines
712 B
C#
Raw Normal View History

2023-07-24 16:38:13 +03:00
using SciFiShipController;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerZone : MonoBehaviour
{
protected ShipControlModule _ship;
protected void OnTriggerEnter(Collider other)
{
if (other.gameObject.TryGetComponent(out ShipControlModule ship))
{
_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");
}
}