Пример #1
0
 /// <summary>
 /// FixedUpdate for this instance.
 /// </summary>
 void FixedUpdate()
 {
     // If have no target - try to get new target
     if ((target == null) && (targetsList.Count > 0))
     {
         target = GetTopmostTarget();
         if ((target != null) && (nav != null))
         {
             // Look at target
             nav.LookAt(target.transform);
         }
     }
     // There are no targets around
     if (target == null)
     {
         if (targetless == false)
         {
             targetless = true;
         }
         else
         {
             // If have no target more than one frame - exit from this state
             aiBehavior.ChangeState(passiveAiState);
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Fixed update for this instance.
 /// </summary>
 void FixedUpdate()
 {
     // If destination reached
     if ((Vector2)transform.position == (Vector2)destination.position)
     {
         // Look at required direction
         navAgent.LookAt(destination.right);
         // Go to passive state
         aiBehavior.ChangeState(passiveAiState);
     }
 }