So I am making a game that will spawn a random game object out of a 10 game objects in an array. The game object is an image put in a empty game object. I don’t know whats wrong with my code but can someone help please? I keep getting this error: ArgumentException: The prefab you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message)
#pragma strict
var obj : GameObject[];
obj = new GameObject[10];
function Start () {
}
function Update () {
var randomObj = Random.Range(0,obj.length);
var randomNum : int;
randomNum = randomObj;
var theObj = obj[randomNum];
Instantiate(theObj, Vector3.zero, Quaternion.identity);
}