Exemplo n.º 1
0
    void MovePlayer()
    {
        Vector2 desiredMove = GetDesiredMove();


        if (desiredMove.x > 0)
        {
            animator.SetAnimationClip("MoveSide", flip: true);
        }

        if (desiredMove.x < 0)
        {
            animator.SetAnimationClip("MoveSide");
        }

        if (desiredMove.y > 0)
        {
            animator.SetAnimationClip("MoveUp");
        }

        if (desiredMove.y < 0)
        {
            animator.SetAnimationClip("MoveDown");
        }

        if (desiredMove == Vector2.zero)
        {
            animator.StopAnimations();
        }

        rigidbody.velocity = desiredMove * moveSpeed;
    }