Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
0
Question by romeo160705 · Mar 19, 2021 at 02:48 PM · error messagetagserror-messagefindgameobjectwithtag

How to disable certain error messages?

I am currently working on a powerup system where my player changes tag. I also have an enemy shooting at the player who has the tag ''player''. Problem is when i use the powerup the tag changes to ''player2'' the enemies doesn't hit me anymore(that isn't a problem) but i also get 999+ errors saying that there isn't a object with tag ''Player'' wich is true. The problem here is that all those error messages makes the game drop fps so is there a way to disable those error messages?

Comment
Add comment · Show 5
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 AbandonedCrypt · Mar 19, 2021 at 02:55 PM 0
Share

You could just program it properly to not throw errors...

avatar image romeo160705 AbandonedCrypt · Mar 19, 2021 at 02:56 PM 0
Share

Im a beginner with c# and if i knew how i wouldn't post about it

avatar image AbandonedCrypt romeo160705 · Mar 19, 2021 at 03:02 PM 0
Share

If you want help you should show some code, you seem to know the source of your error though, as your text conveys.

Show more comments
avatar image toficofi · Mar 19, 2021 at 03:44 PM 0
Share

so, is the power-up supposed to make you invisible to enemies? There's probably a better way that you can tell them that, instead of just changing the player's tag. Maybe you could set a canBeTargeted bool to false and make the enemy check that, and don't fire if so.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by mangosauce_ · Mar 19, 2021 at 03:42 PM

I think the way to go forward here is to avoid using a tag change as a way to change enemy behavior. Disabling the error messages is only skirting around the problem (and I'm 92% sure it can't be done in this case), though it is true that the messages are probably what's caused the performance drop.


Try something like this: add a static variable to the player script, as show below.

     public class PlayerScript : MonoBehaviour
     {
         public static bool isPoweredUp = false;
     }



Then, if you need to check whether the player has picked up the powerup, you can use this if statement:

     public class EnemyScript : MonoBehaviour
     {
         private void Update()
         {
             if (PlayerScript.isPoweredUp == true)
             {
                 //Enemy behavior code
             }
         }
     }


Just be sure to set PlayerScript.isPoweredUp to true when the powerup is picked up, and false when its effects wear off. CompareTag is only really effective if the tag remains the same on a given gameObject. Try to use the above method instead of changing the tag. :)

Comment
Add comment · Show 1 · 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 romeo160705 · Mar 19, 2021 at 04:38 PM 1
Share

Thank you so much for your help! I would never came up with this solution

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.

Follow this Question

Answers Answers and Comments

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

error CS0246: Light Color not working 0 Answers

Could not find file "/Users/KingSloth/Desktop/Unity Files/Take those cars/Temp/StagingArea/Data/Native/build.asm.js 0 Answers

The file MemoryStream is corrupted! Remove it and launch unity again 6 Answers

I have an error "MissingReferenceException" and i dont know why 1 Answer

Swapping a tag for string not working, replacing a tag with a public string, help. 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