Exemplo n.º 1
0
    void WatchPlayer()
    {
        if (!inCombat)
        {
            anim.SetBool("isRunning", true);
            Vector3 distVec = transform.position - player.transform.position;


            if (distVec.x > 0)
            {
                facingRight = true;
            }
            else if (distVec.x < 0)
            {
                facingRight = false;
            }

            if (((facingRight) && (localScale.x < 0)) || ((!facingRight) && (localScale.x > 0)))
            {
                localScale.x *= -1;
            }

            transform.localScale = localScale;


            if (distVec.magnitude < range)
            {
                EnterCombat();
                anim.SetBool("isRunning", false);
                Debug.Log("Attack Added! " + this);
                combatHandler.attackQueue.Add(ChooseAttack());
                combatHandler.EnterCombat();
            }



            distVec /= distVec.magnitude;
            rb.AddForce(distVec * -4);
        }
    }