I am having a problem with the script, i am trying to shoot 5 bullets and after 5 bullets it should have a 5 sec gap before it shoots
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawn_Bullet : MonoBehaviour {
public GameObject bullet;
public GameObject SpawnPos;
public int bulletcount;
private bool isreloading;
private float instantiatetimer;
// Use this for initialization
void Start () {
isreloading = false;
bulletcount = 6;
instantiatetimer = 2.0f;
}
// Update is called once per frame
void FixedUpdate ()
{
if (isreloading==false)
{
if (Input.GetKeyDown(KeyCode.Space))
{
if (bulletcount > 0)
{
Debug.Log ("bulletcount" + bulletcount);
Instantiate (bullet, SpawnPos.transform.position, Quaternion.identity);
--bulletcount;
}
else
{
isreloading = true;
Debug.Log ("reloadstatus" + isreloading);
}
}
}
else if(isreloading==true)
{
StartCoroutine (reload ());
isreloading = false;
}
}
IEnumerator reload()
{
yield return new WaitForSecondsRealtime (3);
bulletcount = 6;
}
}
`