Im trying to make a delay between firing of my vehicle turret but it always throws me
The name “yield” does not exist in current content
Code:
using UnityEngine;
using System.Collections;
public class Turret : MonoBehaviour {
Object emitter;
public GameObject emitter2;
public ExplosionEmitter emitter3;
public Object obj;
// Use this for initialization
void Start () {
emitter = Instantiate ( obj, transform.position, Quaternion.identity);
emitter2 = (GameObject)emitter;
emitter2.transform.parent = transform;
emitter2.transform.Translate(-8, 0, 0);
}
void Update () {
float rot = Input.GetAxis ("test");
transform.Rotate (Vector3.back * (rot * 5));
while (Input.GetKeyDown("b"))
{
StopCoroutine("Fire");
StartCoroutine("Fire");
}
}
IEnumerator Fire ()
{
yield.WaitForSeconds(0.5);
audio.Play ();
emitter2.particleSystem.Play ();
}
}