Answers for "choose random gameobject from a gameobject list"

C#
0

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);
  }
Posted by: Guest on March-07-2020

C# Answers by Framework

Browse Popular Code Answers by Language