animation blend trees with no x0 y1/-1

hi guys I’m trying to get my blend trees working again because I’m facing a issue where my code randomly spins my player(i cant actually get it to duplicate the issue consistently) so i need to switch to blend trees
currently I have a idol left and a idol right blend tree which enters/exits with a “swimming bool”
and then my swimming blend tree holds (numbers in brackets are x,y blends)

  • swimming backwardsup(-1,1)
  • swimming backwards(-1,0)
  • swimming backwardsdown(-1,-1)
  • swimmingforwardsup(1,1)
  • swimmingforwards(1,0)
  • swimmingforwardsup(1,-1)

so there is no true facing up nor down. i set animator float to x1 in start so my player faces the correct direction at game start

currently what is happening is when i press left my player will swim left and return to idol and same for right as well as in the forward/back(up/down)

the problem come when i use only the up or down arrows my sprite will flip to swimming backwards and idol backwards

i thought this was because my x was changing to 0 so i tried storing it in a float as previouschangeX however this would then negate my swim forward/back as x would never be 0

here is my current code

if (currentState == PlayerState.swim || currentState == PlayerState.idle && currentState != PlayerState.dead )
        {
            change = Vector3.zero;
            change.x = Input.GetAxisRaw("Horizontal");   
            change.y = Input.GetAxisRaw("Vertical");
            //angleZ = (Mathf.RoundToInt(transform.localEulerAngles.z));
            if(change != Vector3.zero)//check to see if we are moving and in which direction are we moving
            { 
                animator.SetFloat("moveX" , change.x);     
                animator.SetFloat("moveY" , change.y);
                animator.SetBool("swimming", true);
                currentState = PlayerState.swim;
                movePlayer(); 
            }
            else 
            {   
                animator.SetBool("swimming", false);
                currentState = PlayerState.idle;
            }
        }

void movePlayer()
{
    playerBoundarys();
    change.Normalize();
    rb2d.MovePosition(transform.position + change * movementSpeed * Time.deltaTime);
}
void playerBoundarys()
{
    Vector2 playerPosition = new Vector2(transform.position.x,transform.position.y);
    playerPosition.x = Mathf.Clamp(playerPosition.x, minPositionX, maxPositionX);
    playerPosition.y = Mathf.Clamp(playerPosition.y, minPositionY, maxPositionY);
    transform.position = playerPosition;
}



all code below this line can be fully ignored as it relates to my original controller that randomly gets stuck on a rotation and sometimes constantly spins the player however if someone does wanna glance at it to see if u can spot what is causing my random spinning bug that would also be helpful

void Update()
    {
        //check to see if we are attacking or dead
        if (currentState == PlayerState.swim || currentState == PlayerState.idle && currentState != PlayerState.dead )
        {
            change = Vector3.zero;
            change.x = Input.GetAxisRaw("Horizontal");
            change.y = Input.GetAxisRaw("Vertical");
            angleZ = (Mathf.RoundToInt(transform.localEulerAngles.z));
            if(change != Vector3.zero)//check to see if we are moving and in which direction are we moving
            {
                animator.SetFloat("moveX" , change.x);
                animator.SetFloat("moveY" , change.y);
                animator.SetBool("swimming", true);
                currentState = PlayerState.swim;
                if(change.x != 0 && change.y == 0 || change.x == 0 && change.y != 0)//moving in x or y direction ONLY
                {
                    if(change.x == 1 || change.x == -1)
                    {
                        Direction = animator.GetFloat("moveX");
                        //Debug.Log("direction " + Direction);
                    }
                    //were we at a angle
                    if(angleZ == 30)
                    {
                    //Debug.Log("1");
                    transform.Rotate(Vector3.forward * -30f);//return to 0
                    angleZ = (Mathf.RoundToInt(transform.localEulerAngles.z));//store it
                    movePlayer();
                    }
                    else if(angleZ == 310)
                    {
                        //Debug.Log("2");
                        transform.Rotate(Vector3.forward * 50f);
                        angleZ = (Mathf.RoundToInt(transform.localEulerAngles.z));
                        movePlayer();
                    }
                    else if(angleZ == 0)
                    {
                        //Debug.Log("3");
                        movePlayer();
                    }
                }
                //are we moving on a angle
                if(change.y == 1 && change.x == 1 || change.y == -1 && change.x == -1)//moving up right & down left
                {
                    if(angleZ != 30)
                    {
                    //Debug.Log("7");
                    transform.Rotate(Vector3.forward * 30f);
                    angleZ = (Mathf.RoundToInt(transform.localEulerAngles.z));
                    movePlayer();
                    }
                    else if (angleZ == 30)
                    {
                        //Debug.Log("8");
                        movePlayer();
                    }
                }
                if(change.y == -1 && change.x == 1 || change.y == 1 && change.x == -1)//moving down right and up left 
                {
                    if(angleZ != 310)
                    {
                        //Debug.Log("9");
                        transform.Rotate(Vector3.forward * 310f);
                        angleZ = (Mathf.RoundToInt(transform.localEulerAngles.z));
                        movePlayer();
                    }
                    else if(angleZ == 310)
                    {
                        //Debug.Log("10");
                        movePlayer();
                    }
                }
            }
            else 
            {
                animator.SetBool("swimming", false);
                currentState = PlayerState.idle;
            }
        }

found out you can use blend trees inside of blend trees
added a position inside of the swimming blend tree at x0,y1/-1 and then used those points to enter another blend tree
captured previousChangeX inside my code when x != 0
then used previousChangeX to drive the secondary blend trees

if (currentState == PlayerState.swim || currentState == PlayerState.idle && currentState != PlayerState.dead)
        {
            change = Vector3.zero;
            change.x = Input.GetAxisRaw("Horizontal");
            change.y = Input.GetAxisRaw("Vertical");
            if (change != Vector3.zero)//check to see if we are moving and in which direction are we moving
            {
                if (change.x != 0)
                {
                    PreviousChangeX = change.x;
                }
                animator.SetFloat("previousX", PreviousChangeX);
                animator.SetFloat("moveX", change.x);
                animator.SetFloat("moveY", change.y);
                animator.SetBool("swimming", true);
                currentState = PlayerState.swim;
                movePlayer();
            }
            else
            {
                animator.SetBool("swimming", false);
                currentState = PlayerState.idle;
            }
        }