I’m trying to create an array with a list of objects. What I want to do is randomly select one of these objects and spawn it at the point my cursor is. Any ideas?
Random rnd = new Random();
int myRandom = rnd.Next(1, 13); // will select a (pseudo)random number between 1 and 12
Just use this like rnd.Next(0,yourArraySize) and spawn the object with the index it spits out.
The curser is a 2D object on a 3D space, so I assume you want object to spawn where the camera is looking at instead of the camera position (not tested and not refined like testing if the objects fits there):
// Your array
public Transform[] objectList;
//However and wherever you determinate the mouse click
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit, 100))
{
// Your code to instantiate
int random = (int)Mathf.Floor(Random.Range(0, objectList.Length));
Instantiate (objectList[random], hit.point, Quaternion.identity);
}