So 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 saying the issue is. I have been looking for a few days now on solutions for this and have been unsuccessful so hopefully I will find it here. The error is where spawnManagerspawnManager
first gets called.
This is the code that is trying to get the two values. (andAnd 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 erroerror
spawnManager.randomPowerupWait = Random.Range(7f, 12f);
enemy.speed = 2.75f;
}
Thanks.
Edit: TheseThese are the two pictures of my scenes: Game Scene:
Welcome Scene: