So i have this problem with a text variable that I’m trying to show on the screen. I want to be able to see the text when the power up is in use and when the power up is NOT in use, it shouldn’t be rendered or active in the hierarchy.
I tried using SetActive function and set the bool to true and it works if the object is active when the game starts, but if I disable it in the hierarchy. I get the usual message that the “object reference not set to an instance of an object”
What would be the best way to solve this? Since I just want to show the timer when the power up is in use? Here’s a bit of code:
if(powerUp4 == true)
{
GameObject.Find("PowerUpText").SetActive(true);
destroyEnemiesTimer -= Time.deltaTime;
}
and here’s when I disable it:
if(destroyEnemiesTimer <= 0.0f)
{
GameObject.Find("PowerUpText").SetActive(false);
powerUp4 = false;
}