• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Alan · Dec 23, 2010 at 08:16 PM · iphonetag

UnityException: GameObject has undefined tag! Xcode console message

I get this error when I run my game made using Unity iPhone version 1.7 on my iPod Touch through Xcode's debugger. The exact error message is:

UnityException: GameObject has undefined tag! items.OnTriggerEnter (UnityEngine.Collider other)

(Filename: Line: -1)

It gets spammed a bunch of times in console and as far as I can tell I have all of the tags defined in the Unity Tag Manager. The error does not appear when run on my desktop, only on the iPod. Here is the bit of code, items.OnTriggerEnter:

function OnTriggerEnter (other : Collider){

if(other.tag=="playerBody" || other.tag=="playerHead" || other.tag=="Player" || other.tag=="playerFeet") { ObjectManager.getInstance().ReturnGem(gameObject); Collide(); }

}

How do I get rid of this error?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

7 Replies

· Add your reply
  • Sort: 
avatar image
17

Answer by Shinugami · Mar 29, 2015 at 04:44 AM

This might be the answer or it might not however firstly, Doireth's reply led me to the solution of my problem.

I had just moved my project from Unity 5 beta to Unity 5 normal release. All the tags were in the tag list and all the objects had tags. In editor mode I had no problems with my game however when I used build mode with debugger, I found that I was getting some null references so I investigated and the final error came down to the references not being made because the tags were undefined. This made no sense as all my objects had tags and the tag list was full.

So I OPENED the tag options and clicked 'add tag' to find that when I did this, there was not even one tag in the list. The port from 5 beta to normal 5 seems to have wiped out my tag list.

I re-entered the tag values and the problem is solved.

Thankyou Doireth as your post helped me solve my problem.

When I used:

other.tag == exampleA

I only got a "undefined tag error" however when I used:

other.gameObject.CompareTag("exampleA")

The result I got told me that: "exampleA tag is not defined" So I went into the tag list to RE-define it and saw that there was actually nothing in the list even though selecting from the list normally showed the list contained tags. Editing the tag list revealed that none of those tags actually existed.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BroVodo · Jun 29, 2015 at 05:19 PM 0
Share

$$anonymous$$issing tags might be related to importing objects from a project with the tags into a project without the tags

avatar image sushanta1991 · Jul 09, 2016 at 01:16 PM 0
Share

Thank you for your answer,

"So I OPENED the tag options and clicked 'add tag' to find that when I did this, there was not even one tag in the list."

Same thing happened with me, I added my tag and still i was getting same error , so i checked my prefab, by dragging them in the scene, and found they they were reset to "Untagged" so i set tags of all my gameobject and saved my prefab again. and guess whats still i was getting same error.

restarting software solves most of the issues :D so i restarted unity and tried to play the game, this time everything worked as expected.

avatar image KokodokoGames · Feb 16, 2018 at 10:52 AM 0
Share

I had the same problem, the tags showed in the dropdown, but when opening the tag list, most of the tags were gone!

But in my case, I am not even able to re-add the tags. When I click the plus and enter a new tag, nothing happens. I'm completely stuck.

Why is Unity so buggy? Since I work with Unity, I am fighting bugs almost half of the time.

avatar image Doireth KokodokoGames · Feb 16, 2018 at 10:57 AM 0
Share

Are you sure that you weren't looking at layers or sorting layers? You have to expand the tags list.

avatar image KokodokoGames Doireth · Feb 17, 2018 at 01:20 PM 0
Share

Yes, I think it was a corrupted file somewhere. It happened after building the project. I had to make a new project and copy all the assets to get it working again :(

avatar image sharangsharma09 · Apr 25, 2019 at 07:20 PM 0
Share

You saved a lot of time. Thanks a lot for sharing this answer!

avatar image
6

Answer by Doireth · Apr 25, 2013 at 01:26 PM

I know this is a old question but for posterity's sake I had the same problem and found that:

 other.gameObject.CompareTag("Whatever");

Was a much more stable solution.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Jan 07, 2014 at 05:43 PM 0
Share

Thank you!

avatar image Karwoch · Dec 02, 2015 at 01:04 PM 0
Share

Thank You! After I moved from Unity 5.14 to 5.23, transform.tag == "tag_name" wouldn`t work anymore, even when I had those tags add in Tag list. Only Your solution - CompareTag work as it should.

avatar image MV10 · Feb 06, 2016 at 04:41 PM 0
Share

Unfortunately that won't work with a switch() statement, which is where I ran into tag problems...

avatar image
6

Answer by omarwaleed · Mar 12, 2017 at 03:18 PM

For me the problem wasn't at all related to comparing the string. The problem was that I had added old tags and then removed them and in the hierarchy they appeared before the tags that I was using. I think that Unity was confused or threw an exception during the build but NOT during development. The solution was simple: get rid of the removed tags and this is simply by restarting Unity.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EvyBenita · Aug 10, 2017 at 07:38 PM 0
Share

You hero!! Saved my day, thanks! :)

avatar image stratos_kakalis · Dec 30, 2017 at 01:34 PM 0
Share

Thanks! that did it for me. Wouldn't this be considered a bug then? $$anonymous$$aybe something for the unity $$anonymous$$m to consider fixing?

avatar image KokodokoGames · Feb 16, 2018 at 10:54 AM 0
Share

In my case, restarting is not helping. In one scene, the tags are all correct and present, and in the next scene, the tag list is empty and the game doesn't work --- because my gameObjects are suddenly "untagged".

avatar image TatlaCas · Apr 14, 2018 at 08:48 AM 0
Share

This worked for me. Reloading the project is required when you have removed some tags.

avatar image joshuapeacock · Jun 23, 2018 at 06:55 AM 0
Share

This was my problem too! I actually noticed this when I checked my add tags screen due to Shinugumi's answer! Restarted unity, and boom! Problem Solved.

avatar image
1

Answer by FlameHaze-Yuki · Jul 14, 2017 at 10:11 PM

i had the same exact problem and what i found out is that i had a tag that i deleted but it stayed as "undefined" in unity so when i made the build it became confused as what that tag is the solution was as simple as to just close the unity and reopen it and then rebuild again

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by rbisso · Dec 07, 2011 at 09:57 AM

Just ran into the same problem. This seems to have worked:

     else if( Other.gameObject.tag == "Untagged" )
     {
         // Debug.Log("Hit an object with an undefined tag");
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

little animated loading disc thing in iOS 0 Answers

Strange collision problem with block and terrain 1 Answer

How to make my function only search for objects in the same axis? Code included... 1 Answer

HUGE Texture problems on iPhone when using animated UVs 2 Answers

handling collision with two objects of the same tag 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges