コード例 #1
0
    public override bool Execute()
    {
        Transform player = TargetAI.LookForPlayerArround(TargetAI.DetectRadius);

        if (player != null)
        {
            float d = Vector3.Distance(TargetAI.transform.position, player.position);
            if (d <= stopDistance)
            {
                agent.IsStopped = true;
                return(false);
            }
            if (d <= stopDistance)
            {
                agent.IsStopped = true;
                return(false);
            }
            else
            {
                if (agent.IsStopped)
                {
                    agent.StopDistance = stopDistance;
                    agent.IsStopped    = false;
                    agent.SetDestination(player.position);
                }

                return(true);
            }
        }
        return(false);
    }
コード例 #2
0
 public override bool Execute()
 {
     if (canAttack == true)
     {
         Transform player = TargetAI.LookForPlayerArround(TargetAI.AttackRadius);
         if (player != null)
         {
             Player p = player.GetComponent <Player>();
             if (p != null)
             {
                 canAttack = false;
                 TargetAI.Atack(p);
                 Invoke("resetCD", cD);
                 return(true);
             }
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }