private void OnTriggerExit(Collider other) { AiInfomationReciver reciver = other.GetComponent <AiInfomationReciver>(); if (allRecivers.Contains(reciver)) { Debug.Log("Stop Ai"); reciver.StopAiBehavior(); allRecivers.Remove(reciver); } }
//This Object is touch to a player Component. it's layer is Player Component. Player Component only collider with Enemy. it's not Collide with EnemyComponent private void OnTriggerEnter(Collider other) { AiInfomationReciver reciver = other.GetComponent <AiInfomationReciver>(); if (allRecivers.Contains(reciver)) { return; } else { Debug.Log("Start Ai"); reciver.StartAiBehavior(); allRecivers.Add(reciver); } }