title: How t spawn objects from random places one at a time?
body: <p>I am making an android game for which i need to spawn items from top. I want the spawn places to be horizontally random at the top of my scene. I used these codes which is not giving me anything random and also multiple game objects spawns at same time from same spawner. I want to spawn a single game object at a time and the oher should only spawn after the first one destroyed from the game scene. Plz help me iam new to unity as well as c# and also Stackoverflow.</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Spawner : MonoBehaviour
  {
      public GameObject[] spawnableItems;
  
      // Update is called once per frame
      void Update()
      {
          bool isTimeToSpawn (GameObject itemGameObject)
          {
              spawnableSprites item = itemGameObject.GetComponent&lt;spawnableSprites&gt;();
              float spawnDelay = item.seenEverySeconds;
              float spawnsPerSecond = 1 / spawnDelay;
  
              if(Time.deltaTime &gt; spawnDelay)
              {
                  Debug.LogWarning(&quot;SpawnRate Capped By FrameRate&quot;);
              }
              float threshold = spawnsPerSecond * Time.deltaTime;
  
              if(Random.value &lt; threshold)
              {
                  return true;
              }
  
              else
              {
                  return false;
              }
  
          }
  
  
          foreach (GameObject item in spawnableItems)
          {
              if(isTimeToSpawn(item))
              {
                  Spawn(item);
              }
          }
      }
  
      void Spawn (GameObject myGameObject)
      {
          GameObject myItem = Instantiate(myGameObject) as GameObject;
          myItem.transform.parent = transform;
          myItem.transform.position = transform.position;
      }
  }
  </code></pre>