using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; using Ktyl.Util; public class SafeZone : MonoBehaviour { [SerializeField] private SerialVector3 _respawnPosition; [SerializeField] private SerialFloat _safeTime; private const string PLAYER = "Player"; private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag(PLAYER)) { // set position to middle of safe zone _respawnPosition.Value = transform.position; // start counting safe time when we enter a safe zone _safeTime.Value = 0; } } private void OnTriggerStay(Collider other) { // Check if other game object is Player. if (other.gameObject.CompareTag(PLAYER)) { // TODO: does this have implications for the time freeze ability? _safeTime.Value += Time.deltaTime; } } private void OnTriggerExit(Collider other) { if (other.gameObject.CompareTag(PLAYER)) { // reset safe time when we leave safe zone _safeTime.Value = -1; } } }