spawn prefab multiple times on many empty game objects/

I’m working on a code that hopefully would allow me to spawn a bomberman styled arena on load. I have the “box” prefab made and a grid of empty gameobject “nodes” in which I’d like to spawn these box prefabs.

right now the code creates the correct number of boxes, but says the array I assigned the nodes to is out of range, thus spawning a bunch of boxes to the center point of the scene.

Public class spawnBoxes : MonoBehaviour
{
	public Transform[] spawnNodes; 

	void Start ()
	{
		GameObject prefab = Resources.Load ("box") as GameObject;


		for (int i=0;i<64;i++)
		{
			GameObject go = Instantiate(prefab,spawnNodes*.transform.position,Quaternion.Euler(0,0,0)) as GameObject;*
  •  	go.transform.position = new Vector3 (5, 5, 5);*
    
  •  }*
    
  • }*
    }

An array is a collection with a fixed amount because it designates all the memory it needs in, well, an array with one element after the other and uses the index to count to the right one when used. So in practical terms it means you have to instantiate an array and set how many items it can hold:

spawnNodes = new Transform[64];

Right now your array is null because you haven’t set it yet and reserved the memory for it’s items which means the range is empty and any call will be out of it.