Hello, I am currently having some major issues with this script. Essentially, I am trying to increase the games difficulty over time by disabling and enabling certain game objects. For example, disable and enable one at 5/10/20/50.
public class ScoreController : MonoBehaviour {
private float score;
public GUIText scoreText;
private GameObject asteroidController5;
private GameObject asteroidController15;
void Start()
{
score = 0;
asteroidController5 = GameObject.FindWithTag("ASC0-5");
asteroidController15 = GameObject.FindWithTag("ASC5-15");
}
public void AddScore(int newScoreValue)
{
score += newScoreValue;
UpdateScore();
}
void UpdateScore()
{
scoreText.text = "Score: " + score;
}
void Update()
{
if(score == 5)
{
asteroidController5.SetActive(false);
asteroidController15.SetActive(true);
}
}
}
So when the player reaches a score of 5, I am trying to disable asteroidController5 and replace it with asteroidController15 but I am getting this error message:
object reference not set to an instance of an object
Could anyone help me? Thank you! (I can disable asteroidController5 but cannot enable asteroidController15, asteroidController15 is disabled in the inspector in this helps.)