Hello, this is my first post, so forgive me if i make some mistakes. I’m trying to disable the same 2 script components on 2 different tags. It works fine on one of the tags, but the other one doesn’t work, it gives me the error “Object reference not set to an instance of an object”. Here’s the code:
void PowerUp()
{
WinSound();
foreach (GameObject go in GameObject.FindGameObjectsWithTag("PickUp"))
{
go.GetComponent<Patrol>().enabled = false;
go.GetComponent<Rotate>().enabled = false;
}
foreach (GameObject go in GameObject.FindGameObjectsWithTag("Enemy"))
{
go.GetComponent<Patrol>().enabled = false;
go.GetComponent<Rotate>().enabled = false;
}
}
It works just fine on the PickUp tag, but on the Enemy tag it gives me that error. Hope you can help, please tell if you need more info. Thanks a lot in advance!