Advertisement
Guest User

Untitled

a guest
May 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MoveTo : MonoBehaviour {
  5.  
  6. public Transform[] goals;
  7.  
  8. private bool printDone;
  9. int i = 0;
  10.  
  11. void Start () {
  12. NavMeshAgent agent = GetComponent<NavMeshAgent> ();
  13. agent.destination = goals[i].position;
  14. printDone = false;
  15.  
  16. }
  17.  
  18. void Update () {
  19.  
  20. NavMeshAgent agent = GetComponent<NavMeshAgent> ();
  21. if (agent.remainingDistance < 2 && !printDone) {
  22.  
  23. print ("Found an item: " + goals [i].name + ". This is a " + goals [i].tag);
  24. printDone = true;
  25. agent.destination = goals [i + 1].position;
  26. int i = i + 1;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement