Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        float distance = Vector3.Distance(player.position, myTransform.position);

        if (distance < maxDist)
        {
            Attack();
        }
        if (attackTimer > 0)
        {
            attackTimer = attackTimer * Time.deltaTime;
            //animController.SetBool("Attack", false);
        }
        else if (attackTimer < 0 || ph.currHealth <= 0)
        {
            //if player is dead
            attackTimer = -1;
            c.CamSwitch();
            animController.SetBool("Attack", false);
        }
        else
        {
            animController.SetBool("Attack", false);
        }

        if (!(isDead))
        {
            nav.SetDestination(player.position);
            animController.SetFloat("speed", Mathf.Abs(nav.velocity.x) + Mathf.Abs(nav.velocity.z));
        }
    }