random between 3 gameobjects

I can’t “create” a c# script that, from three public gameobjects activate one and disactive the others two, everytime the player “input.GetButton(“button”);”

using UnityEngine;
using System.Collections;

public class cambiowall : MonoBehaviour {

private Collider player_on;
private playersw movOn;
public GameObject murobase;
public GameObject muro_blu;
public GameObject muro_giallo;
public GameObject muro_arancione;

using UnityEngine;

using System.Collections;

public class cambiowall : MonoBehaviour {

private Collider player_on; //ok
private playersw movOn; //ok
public GameObject murobase;
public GameObject muro_blu;
public GameObject muro_giallo;
public GameObject muro_arancione;

void Start (){
	movOn = GameObject.Find("player_1").GetComponent<playersw>(); //ok
	muro_blu.SetActive (false);//ok
	muro_giallo.SetActive (false);//ok
	muro_arancione.SetActive (false);//ok
}
void OnTriggerStay	 (Collider other){

	player_on = other;//ok
	if (player_on.name == "player_1") {//ok
		if (movOn.mov1on.enabled==true) {//ok
			if (Input.GetButtonDown("muri")) { //not if... "everytime"
				Random //i don't know

			}
		}
	}



}

}

Your code is hard to read… but I’ll try to help here. If you want one to activate at random, try this:

public GameObject[] objs;

void SpawnRandom()
{
	for (int i = 0; i < objs.Length; i++)
	{
		objs*.SetActive(false);*
  • }*
  • objs[Random.Range(0,objs.Length)].SetActive(true);*
    }
    Just have the three objects you want to spawn added to the array there. You can do that by dragging them in to it in the unity editor.