I am trying to randomly select two items from the list. These items are then set visible in the scene. The problem is, that sometimes it picks the one that has been selected in previous loop.
How do I exclude the first selection?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BeamManager3 : MonoBehaviour {
public List<GameObject> LargeBeamObject = new List<GameObject>();
void Start () {
LargeBeamPlayerGenerator();
}
void LargeBeamPlayerGenerator(){
for (int i = 0; i < 2; i++){
int randomGameObject = Random.Range(0,4);
GameObject selectedGameObject = LargeBeamObject[randomGameObject];
MeshRenderer visible = selectedGameObject.GetComponent<MeshRenderer>();
visible.enabled = true;
}
}
}