The function below is supposed to create a new instance of SolarSystem_Manager
and add it to a list however when var clone = Instantiate(_solar)
is run, it returns a nullreference
error. All instances of _solar
have the same ID when I created multiple and this was 0 and changing the variables of one also changes the variables of the others. Do you know what I am doing wrong?
private void createSolarSystem()
{
SolarSystem_Manager _solar = new SolarSystem_Manager();
_solar.solarSystem = new SolarSystem(transform.GetComponent<Galaxy>(), Random.Range(9, 10), new List<LQPlanetManager>(), new SunManager());
var clone = Instantiate(_solar);
solarSystems.Add(clone);
}