using System.Collections; using System.Collections.Generic; using UnityEngine; public class TrappedPerception : MonoBehaviour { private List firemanList = new List(); RaycastHit hit; public List FiremanList { get { return firemanList; } } void Update() { Ray ray = new Ray(transform.position, transform.forward); if (Physics.Raycast(ray, out hit)) { if (hit.collider.tag == "fire") { if (Vector3.Distance(transform.position, hit.point) < 10) { Debug.Log(hit.collider.name); } } } } public void OnTriggerExit(Collider other) { if (other.tag=="Player"&&firemanList.Contains(other.gameObject)) { firemanList.Remove(other.gameObject); Debug.Log(other.name+"leave"); } } public void OnTriggerEnter(Collider other) { if (other.tag == "Player" && !firemanList.Contains(other.gameObject)) { firemanList.Add(other.gameObject); Debug.Log(other.name + "enter"); } if (GetComponent()) { GetComponent().FireManNear = true; } } }