Animation blocking player's rotation

I have a player object which has some animations in it. Moving right or left was okay at the beginning then i added moving up and down. But then my rotation function became useless. Even when I play project I cannot change rotation from editor.( Now moving up and down is okay but transform.Rotate(0, 180, 0); is not working anymore )

public void MovementRight()
{
if(IsRight)

{

        rb.velocity =  Vector2.right*speed;
        anim.SetBool("Swim",true);
        
    }
    else
    {
        transform.Rotate(0, 180, 0);
        rb.velocity = Vector2.right * speed;
        IsRight = true;
        anim.SetBool("Swim", true);
      

    }
   
    
} 

public void MovementUp()
{
if (flat)
{

        flat = false;
        up = true;
        anim.SetBool("Up", true);
        rb.velocity = Vector2.up * speed;

    }
    else if (down)
    {
        anim.SetBool("TurnFlatFromDown", true);
        flat = true;
        up = false;

    }
    else if (up)
    {
        rb.velocity = Vector2.up * speed;
    }
}
pu

If your animation is working without movement and your movement is working without animation, why not decouple the two entirely? Maybe create an empty game object that has the movement stuff on it and then, inside that game object, have the animated thing along with the animator.

@MaxGuernseyIII GuernseyIII
My animation starts with movement but I will try that parenting object thing.Thank you for your help.

Problem is solved!
Basically, I was trying to animate parent object but my imported object was using its child object to use animation. So I changed animation transform from parent to child and put rb.Transform.rotate (0,180,0) instead Transform.rotate and everything became fine again.