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

public class TriggerZoneEnem : MonoBehaviour {
	public GameObject enemy;
	public GameObject player;
	public float initSpeed = 6.0f;
	private UnityEngine.AI.NavMeshAgent agent;
	private Vector3 startingPoint;

	void Start(){
		agent = enemy.GetComponent<UnityEngine.AI.NavMeshAgent>();
		agent.autoBraking = true;
		agent.speed = initSpeed;
		startingPoint = enemy.transform.position;

	}
	void Update(){
	}
	void OnTriggerStay(Collider other){
		if(other.tag == "Player"){
			agent.destination = player.transform.position;
		}
	}
	void OnTriggerExit(Collider other){
		agent.destination = startingPoint;
	}

}
