Hi everyone, I’m trying to create a function that a finds a gameobject with a tag and then adds the gameobject’s children to a transform array. When I run the script the console gives me a null reference exception and it points to line 5. Any reason why? I don’t see anything that is null here.
public Transform[] someTransformArray;
void FindGameObjectsChildrenByTag(string tag, Transform[] transformArray){
GameObject go = GameObject.FindGameObjectWithTag(tag);
transformArray = go.GetComponentsInChildren<Transform>();//Null Reference Exception
}
void Awake(){
FindGameObjectsChildrenByTag("someTag", someTransformArray);
}