using UnityEngine; using UnityEngine.Events; [RequireComponent(typeof(BoxCollider))] public class Teleporter : MonoBehaviour { [SerializeField] private Transform _out; [SerializeField] private UnityEvent _onTeleport; private void OnEnable() { GetComponent().isTrigger = true; } private void OnTriggerEnter(Collider col) { if (!col.gameObject.TryGetComponent(out CharacterController cc)) return; var go = col.gameObject; var outPos = _out.position; cc.enabled = false; go.transform.position = outPos; cc.enabled = true; } }