- Home /
Question by
Crandemolisher9 · Mar 29, 2021 at 08:06 PM ·
errorinstantiatenullreferenceexceptioncopy
Instantiating class creating copies with same instance ID of 0
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);
}
Comment
Your answer
Follow this Question
Related Questions
[Closed]NullReferenceException on Object Instantiation onto game world 2 Answers
Simultaneous Null Reference Exception and expected value 1 Answer
NullReferenceException and m_InstanceID == 0 on LoadLevel (C#) 1 Answer
After Instantiating a Prefab I get a NullReference Error even though the Object was created 2 Answers