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

public class CowMooveScript : MonoBehaviour {

	public GameObject thePlayer;

	private float interval;
	private float counter = 0;

	public GameObject bullet;

	// Use this for initialization
	void Start () {
		interval = Random.Range (5, 15);
	}
	
	// Update is called once per frame
	void Update () {
		//look at the player
		//move towards the player

		this.gameObject.transform.LookAt (thePlayer.transform);
		this.gameObject.transform.position += transform.forward * 1.0f * Time.smoothDeltaTime;


		counter += Time.smoothDeltaTime;


		if (counter >= interval) {
			counter = 0;
			//shoot a boolet

			GameObject.Instantiate (bullet, gameObject.transform.position, gameObject.transform.rotation);

		}
	}
}
