Ok so i’m making a on rails shooter and trying to build enemy intelligence,
I got the enemies spawning walking to positions, targeting the players. But I can’t limit the reloading, or shooting speed they reload all the clips in 1 go and shoot way to fast, as the case statement is in the update method, confused as to where else to put it.
void Update () {
switch(caseCont)
{
case 1:
RunToCover();
Debug.Log("Running to Cover");
break;
case 2 :
HideCover();
Debug.Log("Hiding");
break;
case 3:
Targetting();
Debug.Log("Aiming");
break;
case 4:
Shooting();
Debug.Log("Shooting");
break;
}
void Reload()
{
StartCoroutine (ReloadDelay());
caseCont = 2;
}
IEnumerator ReloadDelay()
{
PlayReloadAudio();
yield return new WaitForSeconds(ReloadTime);
if(Clip > 0)
{
BulletsLeft = BulletPerClip;
Clip = Clip - 1;
}
}