0
\$\begingroup\$

In the log, it says

UnityException: Tag: car is not defined.
  at PlayerController.OnTriggerEnter (UnityEngine.Collider other) [0x00000] in <filename unknown>:0 

I'm checking against the tag car when colliding, why does this happen? I have tagged the object, see picture below

heres some code

void OnTriggerEnter(Collider other)
{
    if (other.gameObject.CompareTag("car"))//error here
    {
        //more code
    }
}

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I think you didn't apply the changes. Anyways it was a different thing. Can you post some of your code and full inspector window snap? \$\endgroup\$ – Hamza Hasan Dec 14 '15 at 21:46
  • \$\begingroup\$ @HamzaHasan yeah just changed the Q. Which part of the code do you want. I'll add some to the question \$\endgroup\$ – Hamzah Malik Dec 14 '15 at 21:47
  • \$\begingroup\$ Seems everything fine. Try by restarting Unity. May be inspector settings got corrupt and may need restart. \$\endgroup\$ – Hamza Hasan Dec 14 '15 at 21:51
  • \$\begingroup\$ I don't think your tags are there. \$\endgroup\$ – Alec Teal Dec 14 '15 at 21:59
  • \$\begingroup\$ Its a bug. If you can reproduce it, please report it to Unity \$\endgroup\$ – Hamza Hasan Dec 14 '15 at 22:29
3
\$\begingroup\$

The problem was that there weren't actually any tags in Edit > Project Settings > Tags and Layers, even though there were in the inspector

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.