using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bowman : MonoBehaviour {

	Animator anim;
	public GameObject flecha, spawner;

	void Start () {
		anim = GetComponent<Animator> ();
	}

	void Update () {
		if (Input.GetKeyDown (KeyCode.X)) {
			print("Disparandos");
			StartCoroutine(WaitFor (1f));
		}

	}
	void OnMouseDown(){
		
	}


	private IEnumerator WaitFor(float seconds){
		anim.SetBool ("shoot", true);
		yield return new WaitForSeconds (seconds);
		Instantiate (flecha, spawner.transform.position, spawner.transform.rotation);
		anim.SetBool ("shoot", false);
	}

}
