choose a randome gameobject from a list code example
Example 1: how to choose a random child in a gameobject unuity
public GameObject YourGameObject;
int randomChildIdx = Math.Random(0, YourGameObject.transform.childCount);
Transform randomChild = YourGameObject.transform.GetChild(randomChildIdx);
Example 2: choose random gameobject from a gameobject list
void Fire()
{
if(Logs.Count == 0)
{
CancelInvoke();
return;
}
int randomIndex = Random.Range(0, Logs.Count);
Logs[randomIndex].transform.position = transform.position;
Logs[randomIndex].transform.rotation = transform.rotation;
Logs[randomIndex].SetActive(true);
Logs.RemoveAt(randomIndex);
}