- Home /
Question by
maroonswordsman · Jul 12, 2016 at 08:02 AM ·
inputdelay
Delay for seconds when key is held down?
Hello I am very new to Unity and am trying to make a shooting game in which when the space key is pressed down the gun charges then shoots. I want it to wait for 0.3 seconds before the gun fires off because I want an animation to play first. Here is the scripts I wrote:
void Start()
{
StartCoroutine("Shoot",0.3f);
}
IEnumerator Shoot()
{
yield return new WaitForSeconds (0.3f);
Bam ();
}
void Bam()
{
transform.Translate (0, 0, 12);
}
void Update () {
if (Input.GetKey (KeyCode.Space))
Shoot();
Comment