Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (target == null)
        {
            target = PathFinding.findMaskObjectives(this.transform, lookRange, playerMask, target, null);
        }
        else
        {
            player = target.GetComponent <Player>();
            agent.SetDestination(target.position);
        }

        if (player != null)
        {
            if (Vector3.Distance(transform.position, target.position) < 1.5f)
            {
                if (!isAttacking)
                {
                    //play attack;
                    StartCoroutine(startAttack());
                }
            }
        }

        PathFinding.Dead(this.gameObject, life);
    }