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

public class CowSpawnScript : MonoBehaviour {

    private float timeCounter = 0f;
    private float randomInterval;

    private float minRange = 0f;
    private float maxRange = 5f;

    public GameObject cow;

	// Use this for initialization
	void Start () {
        randomInterval = Random.Range(minRange, maxRange);
	}
	
	// Update is called once per frame
	void Update () {
        timeCounter += Time.smoothDeltaTime;

        if(timeCounter >= randomInterval)
        {
            timeCounter = 0;

            GameObject newCow = Instantiate(cow, this.gameObject.transform.position, this.gameObject.transform.rotation);

            newCow.GetComponent<CowMooveScript>().thePlayer = GameObject.Find("Camera (eye)");

            randomInterval = Random.Range(minRange, maxRange);

        }
	}
}
