Hello!
I have been making a game, and I’m at the point of which I’m adding in Enemy AI who swing and attack the player. Unfortunately, I can’t get the detection to work. Collision is pretty rudimentary, but for whatever reason, it’s not clicking. I have been reading several articles online, trying to understand why it’s not working, but nothing I have read has bore a viable solution.
For the record, both the enemy AI and player have Mesh Colliders, neither of them have the “Trigger” option or the convex option selected. Both have Rigidbodies. I put a debug.log bit in my code to see if it would detect anything, and it does not…If I’m missing something, please let me know.
using UnityEngine;
using System.Collections;
public class EnemyManager : MonoBehaviour {
void OnColliderEnter(Collision coll) {
Debug.Log ("Object Detected");
if (coll.gameObject.tag == "Player") {
Debug.Log ("Hit Player");
}
}
}