private NavMeshAgent MyAgent; //instantiates a navmeshagent named MyAgent // Start is called before the first frame update void Start() { EnemyHealth = 100; //sets EnemyHealth to 100 waypoints = GameObject.FindGameObjectsWithTag("EnemyWayPoint"); // sets waypoint equal to all objects with the tag "EnemyWayPoint" MyAgent = GetComponent <NavMeshAgent>(); //sets MyAgent equal to this objects NavMeshAgent MyAgent.destination = waypoints[CurrentWaypoint].transform.position; //sets MyAgents destination equal to the waypoint in the CurrentWayPoint position }