Esempio n. 1
0
 public void SetNewTarget(GameObject target, bool isEnemy)
 {
     if (prev == null && target != null && !firstCall)
     {
         foreach (FlockAgent agent in agents)
         {
             if (agent != null)
             {
                 Walk walk = agent.GetComponent <Walk>();
                 if (isEnemy)
                 {
                     walk.SetTarget(target.transform);
                     walk.MoveForwardTo(target, false);
                 }
                 else
                 {
                     Collider2D[] ans = new Collider2D[1];
                     ans[0] = target.GetComponent <Collider2D>();
                     walk.MoveToTarget(ans, false);
                 }
             }
         }
         this.prev = target;
     }
     firstCall = false;
     prev      = target;
 }