title: How to spawn objects in Unity?
body: <p>I am trying to build a flappy bird like game and I am trying to spawn enemy birds and gold coins so I have written the C# code and the made the prefabs, but when I run the bird and the coins are not respawning.</p>
  <p>This is the respawn code:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class SpawnPlayer : MonoBehaviour
  {
      public GameObject GameObjectToSpawn;
      private GameObject Clone;
      public float timeToSpawn = 4f;
      public float FirstSpawn = 10f;
  
  
      // Update is called once per frame
      void Update()
      {
          FirstSpawn -= Time.deltaTime;
          if (FirstSpawn &lt;= 0f)
          {
              Clone = Instantiate(GameObjectToSpawn, gameObject.transform.localPosition, Quaternion.identity) as GameObject;
              FirstSpawn = timeToSpawn;
  
          }
      }
  }
  </code></pre>
  <p>screenshot of unity:
  <a href="https://i.stack.imgur.com/RaR4q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RaR4q.png" alt="enter image description here" /></a></p>
  <p>This where i am respawning the first enemy bird:</p>
  <p><a href="https://i.stack.imgur.com/0teLx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0teLx.png" alt="enter image description here" /></a></p>