Beispiel #1
0
    private IEnumerator Backstep()
    {
        if (Input.GetButtonDown("Backstep") && isCharOnGround)
        {
            isBackstep = true;
            Vector2 diagonalVector;

            if (playerGameObject.IsFacingRight)
            {
                diagonalVector = new Vector2(-1.0f, 1.0f);
            }
            else
            {
                diagonalVector = new Vector2(1.0f, 1.0f);
            }

            rigidbody2D.AddForce(diagonalVector.normalized * backStepDiagonalForce);

            animator.SetTrigger("BackstepTrigger");
            animator.SetBool("IsBackstep", isBackstep);

            yield return(backStepAnimation.WaitForAnimationToFinish());

            isBackstep = false;
            animator.SetBool("IsBackstep", isBackstep);
        }
    }