I'm trying to access my enemy and spawning values from two different classes into a class that is trying to change them both. Although when I do this I keep getting a Null Reference Exception error. The error is where spawnManager
first gets called.
This is the code that is trying to get the two values. (And just to note I am trying to access these two values from my Welcome scene and these two values are in my Game scene but I do not know if this is affecting anything):
private EnemyAI enemy;
private SpawnManager spawnManager;
void Start() {
spawnManager = GetComponent<SpawnManager>();
enemy = GetComponent<EnemyAI>();
}
public void onEasy() {
spawnManager.enemyShipWait = Random.Range(1f, 3f); <-- This line has the error
spawnManager.randomPowerupWait = Random.Range(7f, 12f);
enemy.speed = 2.75f;
}
These are the two pictures of my scenes: Game Scene:
Welcome Scene: