Im instantiating a GameObject then trying to add it into a list in another script. The instatiation happens just fine, but when I try to add the obj into a List, I get the error: NullReferenceException: Object reference not set to an instance of an object
Add debugging. You need to figure out what is null. On line 9, GetComponent is designed to return null if the component is not found, but you’re not checking if that occurs. On lines 15 and 16 playerScript.unityList could be null.
Why aren’t you just adding “obj” to the list though? I don’t understand your transform.Find and new GameObject lines when the first sentence of your post says you are adding the instantiated GameObject to the list. The instantiated GameObject is obj.
yes, you are right, for some reason the list was null, now I managed to fix it, thanks!
and btw I was trying to add the child of the instatiated object