• 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
0

Answer by Grumshow · Dec 03, 2017 at 10:39 PM

Just wanted to comment here in case anyone had the specific problem I had in relation to this, that I solved using the method mentioned by @omarwaleed and @FlameHaze-Yuki

I had a Character controller landing on a moving platform, and was changing the parent to the platform in order to have the player move with the platform. This was done using a Trigger box collider that I tagged "platform" after a couple of typos and removed tags.

This worked great in the editor, but when I built to the android device the player would just slide off like the event OnTriggerEnter was not happening. I also tried OnTriggerStay, to no avail. I also tried searching Google for "OnTriggerEvent not firing on Android" and "Parenting CharacterController."

It was only after opening Android Monitor in Android Studio and seeing the error "UnityException: GameObject has undefined tag!" pop up, that I found this thread and solved by restarting Unity. Definitely going to be my go to first attempt at any future problem solving!

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 Radical · Sep 02, 2017 at 09:04 AM

I was seeing the same error message when running on Android, but not within the editor. The same logic error was occurring on iOS, but I haven't checked the logs to see if this was the exact error message.

This particular project was upgraded from Unity 4 to Unity 5.6.1f1. What I found is that in Project Settings | Tags and Layers there were a few tags marked as "Removed", and a message from Unity stating that they would actually be removed the next time the project was loaded. Unfortunately, reloading the project would never remove them.

My hunch was that Unity was in a state where it thought the tags were up to date, and that there was nothing to do to them at project load.

The answer was to add a temp Layer, save the project, then reload the project. I restarted Unity just to be safe. The "Removed" tags were then actually removed, and everything is now working properly on Android builds. I'll test iOS as well, but I would bet money it's fixed as well.

My assumption is that making a change (adding a layer) marked a dirty flag internally and Unity's cleanup logic at project load now saw that there was a change to the Tags and Layers and did it's normal processing. The tags probably got screwed up when upgrading the project from Unity 4 to Unity 5. That I don't know. The tags look fine in Unity 4.

Afterwards, I did of course remove the temp layer.

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
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
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
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!

  • 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