Hello all. I am trying to update the parent-child relationships of some gameobjects that are contained in a GameObject fixed-length array (size 3). Basically, I have three simple gameobjects (no physics data, just mesh rendering, etc) loaded from Prefabs in my scene, each of which has a child GameObject that I want to assign as a child to one of three other, empty gameobjects, which act as position markers in my scene. My current approach to this is seen in “initializeVonSouffleQueue()” below.
Basically, however, I am having troubles with NullReferenceException errors, mostly coming from line 6 from the top of “updateVonSouffleQueue()” as below. I’m not quite sure how to fix things, however. At its simplest, I’m trying to do what is seen in this link, only with gameobjects contained inside arrays rather than single variables: Parenting and Re-Parenting
Any insight into how to better approach the matters of dynamic reassignment of array members and gameobject parent-child relationships in script would be helpful. Thanks.
void initializeVonSouffleQueue() {
for (int i = 0; i < souffleQueue.Length; i++)
{
souffleQueue _= Instantiate((scriptCamera.ingredientTypeItem[0][Random.Range(0, numNeutralIngredient)] as GameObject).transform.FindChild("prefabIngredientFace"), queueGUI*.transform.position, Quaternion.identity) as GameObject;*_
souffleQueue_.transform.parent = queueGUI*.transform;
}*_
}
public void updateVonSouffleQueue() {
for (int i = 0; i < souffleQueue.Length-1; i++)
{
souffleQueue = souffleQueue[i+1];
souffleQueue_.transform.parent = queueGUI*.transform;
}
souffleQueue[2] = Instantiate((scriptCamera.ingredientTypeItem[0][Random.Range(0, numNeutralIngredient)] as GameObject).transform.FindChild(“prefabIngredientFace”), queueGUI[2].transform.position, Quaternion.identity) as GameObject;
}_
[1]: http://wiki.etc.cmu.edu/unity3d/index.php/Parenting_&_Re-Parenting*