Object reference not set to instance of object in array : <p>I am making a random object spawn system for my game. The error I'm running into is when assigning the spawns and objects to an array. I am doing this so that a random number generator can pick one from the array to use. However I am getting the error message </p>

<p><code>NullReferenceException: Object reference not set to an instance of an object
RandomSpawn.Start () (at Assets/RandomSpawn.cs:26)
</code></p>

<p>The area that it is coming up in is my start function where I am assigning the spawns and objects to their arrays.</p>

<pre><code>public Transform spawn1;
public Transform spawn2;
public Transform spawn3;

public GameObject obj1;
public GameObject obj2;
public GameObject obj3;

private Transform[] spawns;
private GameObject[] objects;

private bool[] spawnUsed;
private bool[] objectUsed;

private int randomRun = 0;

void Start()
{
    spawns[0] = spawn1;
    spawns[1] = spawn2;
    spawns[2] = spawn3;

    objects[0] = obj1;
    objects[1] = obj2;
    objects[2] = obj3;
}
</code></pre>

<p>I am not sure why I am getting the error as I cannot see any mistakes in how I am assigning them. The variables are the same variables as the arrays that I am assigning them too. I have made sure that they are all attached to the correct part of the script in Unity too.</p>
