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?

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. :slight_smile: