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

public class cowMoove : MonoBehaviour {

    private GameObject thePlayer;
    string dudeName = "Dude";

    public GameObject boolet;
    int counter = 0;

	// Use this for initialization
	void Start () {
        thePlayer = GameObject.Find(dudeName);
	}
	
	// Update is called once per frame
	void Update () {

        //look at the player
        this.gameObject.transform.LookAt(thePlayer.transform);

        //take a step towards the player
        this.gameObject.transform.position += transform.forward * 2.0f * Time.deltaTime;

        //shoot the dude
        counter++;

        if (counter >= 100)
        {
            //shoot a bullet
            counter = 0;

            GameObject newBullet = GameObject.Instantiate(boolet);

            newBullet.transform.position = this.gameObject.transform.position;
            newBullet.transform.rotation = this.gameObject.transform.rotation;
        }
	}
}
