I’m trying to detect whether or not my player controller is colliding with a game object with a specific tag. Here’s my code so far:
//Detect collisions
void OnTriggerEnter (Collider targetObj)
{
Debug.Log("Hit!");
//Detect collisions with body
if (targetObj.gameObject.tag == ("Body"))
{
Debug.Log("Hit Self!");
}
}
This is the collider component for the object I want to detect hits from:
But for whatever reason, this isn’t working. I’ve double-checked, and the gameObjects that I want to detect collision for have the appropriate tag, “Body”. I’ve also tried using regular colliders and triggers as well (triggers are preferred). No collisions are being detected, no matter the gameObject.