I have a very simple script that prints a message when a gameobject with a certain tag enters a triggercollider. And the thing is that when the enemy enters nothing happens but when the player walks in it works just fine. Heres the script:
void OnTriggerEnter (Collider other) {
if (other.gameObject.tag == "Enemy") {
print("Enemy");
}
if (other.gameObject.tag == "Player") {
print("Player");
}
}
The enemy is using the nav mesh agent with some simple code to make it follow the player. Heres that code:
private NavMeshAgent agent;
public Vector3 playerPos;
public GameObject player;
void Start() {
agent = GetComponent<NavMeshAgent>();
}
void Update() {
playerPos = player.transform.position;
agent.SetDestination(playerPos);
}