Question by
unity_JKfie4JBOVqowQ · Aug 23, 2021 at 07:03 AM ·
collisionerrortag
Collision doesn't detect tag..
So I'm having the weirdest issue ever. I've never had a problem like this one, where every gameObject I collide with no matter the tag prints out the same thing - the else statement. I've made sure the objects are tagged with the correct naming, I have a rigidbody on one of the objects, and there's no warnings. I've gotten up to the point of copying a similar script and changing the names, which gave me the same result. I'm pretty sure it's somewhere within the settings of scene or something like that. Here's a sample code -
using UnityEngine;
public class CollisionHandler : MonoBehaviour
{
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.CompareTag("Friendly"))
{
print("Friendly");
}
else if (collision.gameObject.CompareTag("Enemy"))
{
print("Enemy");
}
else
{
print("done");
}
}
}
Comment
i believe it was something with the collision matrix settings? anyways glad you found a solution yourself