Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MoveTo : MonoBehaviour {
- public Transform[] goals;
- private bool printDone;
- int i = 0;
- void Start () {
- NavMeshAgent agent = GetComponent<NavMeshAgent> ();
- agent.destination = goals[i].position;
- printDone = false;
- }
- void Update () {
- NavMeshAgent agent = GetComponent<NavMeshAgent> ();
- if (agent.remainingDistance < 2 && !printDone) {
- print ("Found an item: " + goals [i].name + ". This is a " + goals [i].tag);
- printDone = true;
- agent.destination = goals [i + 1].position;
- int i = i + 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement