title: Delay in shoot (Unity and C#)
body: <p>I am making shooting in Unity, what I want is to make a little delay, for example: to be able to shoot in every 0.5 seconds. Check the script, I want my bullet prefab to appear (instantiate) after 0.5 sec delay.</p>
  
  <pre><code>private Rigidbody2D rb2d;
  private float h = 0.0f;
  public float Speed;
  public Transform firePoint;
  public GameObject bulletPrefab;
  
  
      // Start is called before the first frame update
  void Start()
  {
      rb2d = GetComponent&lt;Rigidbody2D&gt;();
  
  }
  
  // Update is called once per frame
  void Update()
  {
      h = Input.GetAxisRaw("Horizontal");
      if (h != 0.0f)
      {
          rb2d.velocity = new Vector2(h * Speed, rb2d.velocity.y);
      }
      if (h == 0.0f)
      {
          rb2d.velocity = new Vector2(0, rb2d.velocity.y);
  
      }
  
      if (Input.GetKeyDown(KeyCode.Space))
      {
          Shoot();
      }
  }
  
  
  void Shoot()
  {
      Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
  }
  </code></pre>