Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!CanFire())
        {
            return;
        }

        Vector3 direction = (target.position - transform.position).normalized;

        if (EnemyFunctions.CanSeeTarget(transform, target, "Player", maxRange))//  CanSeeTarget())
        {
            gun.Fire(direction);
            timeSinceFiring = 0.0f;
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 protected override void Update()
 {
     if (EnemyFunctions.CanSeeTarget(transform, chaseTarget, "Player", 100))
     {
         destination = chaseTarget.position;
     }
     else
     {
         Vector2 moveDirection = agent.velocity.normalized;
         if (moveDirection == Vector2.zero || agent.pathStatus == UnityEngine.AI.NavMeshPathStatus.PathInvalid)
         {
             destination = EnemyFunctions.RandomNavSphere(transform.position, maxRoamRange, -1);
         }
     }
     base.Update();
 }