hi, so im trying to make a game where you have to stay off a random block on a grid (they are all squares) and I know how to reference one gameobject, but how would i reference mutliple, choose a random one out of all of them all in one script. And what object would i attach that script to?
You need to create script which will contain public/SerializeField array of GameObjects, and fill it via inspector.
To select random from it, you simply use random function:
using UnityEngine;
public GameObject[] myObjects;
int randomIndex = UnityEngine.Random.Range(0, myObjects.Length);
var randomObject = myObjects[randomIndex];
I would attach this script to some GameObject and made all grid squares as children of this GameObject, it would make sense.