I’m trying to achieve a delay between gunshots here’s my script:
using UnityEngine;
using System.Collections;
public class AIscript : MonoBehaviour {
IEnumerator reloadTimer()
{
yield return new WaitForSeconds(2);
}
[COLOR="red"].....................................[/COLOR]
void FindPlayerInput ()
{
if ((Input.GetMouseButtonDown (0))(shotGun))
{
HandleShotGun();
}
}
[COLOR="red"]......................................[/COLOR]
void HandleShotGun ()
{
tempVector = Quaternion.AngleAxis(8f, Vector3.up) * inputRotation;
tempVector = (transform.position + (tempVector.normalized * 0.8f));
GameObject objCreatedSGBullet = (GameObject)
Instantiate(ptrScriptVariable.objShotGunBullet, tempVector, Quaternion.LookRotation(inputRotation) ); // create a bullet, and rotate it based on the vector inputRotation
Physics.IgnoreCollision(objCreatedSGBullet.collider, collider);
audio.PlayOneShot(shotgunSound);
[COLOR="darkorange"]StartCoroutine(reloadTimer());[/COLOR]
[COLOR="red"]......................................[/COLOR]
but nothing happens… what i’m doing wrong?
p.s. in javascript it was much easier