Quantcast
Viewing latest article 25
Browse Latest Browse All 68

Make one unit move towards another.

Edit: Okay tossed out the previous script after digging up some tutorials yet this still isn't working any help? I am working on some basic scripts so that I can use them as the basis for a few RTS games I have in mind. I wrote out this script and applied it but for some reason the unit it is attached to is not moving towards the enemy. Anyone have any ideas what I am doing wrong? Oh I should also note that when I put it in the editor and tell it to just go after the object it will start flying off like crazy in some random direction.


      private var human : Transform;
      private var nav : NavMeshAgent;
      private var LOS = 10;

      function Start () {
      human = GameObject.FindGameObjectsWithTag ("Human").transform;
      nav = GetComponent (NavMeshAgent);
      }

      function Update () {
       nav.SetDestination(human.position);
      }

Also I have another script to create the tags as vars it goes

       public static var human : String = "Human";

Viewing latest article 25
Browse Latest Browse All 68

Trending Articles