How can I stop my character from walking during the attack animation?

I am working with Unity in 2D. My character can move around successfully and when not moving, he can also attack. But if he attacks while moving he doesn’t stop like I want him to. With this code he stops walking only if I hold down the button for attack. I want him to attack and stop moving until the animation for attack stops and then go back to walking if the movement buttons are held down. I have no clue what to do.

    void Update()
    {
        CheckInput();
    }


    void CheckInput()
    {

        IsMoving = false;
        IsAttacking = false;

        var horiz = Input.GetAxisRaw("Horizontal");
        var vert = Input.GetAxisRaw("Vertical");
        var attack_input = Input.GetAxisRaw("Attack");

        if (horiz < 0 || horiz > 0 || vert < 0 || vert > 0)
        {
            IsMoving = true;

            if (rigidBody.velocity.x != 0 || rigidBody.velocity.y != 0)
            {
                PrevDirection = rigidBody.velocity;
            }

        }

        if (attack_input > 0)
        {
            IsAttacking = true;
        }

        if (IsAttacking == false)
        {
            forceDelta = new Vector2(horiz, vert);
            CalculateMovement(forceDelta * speed);
        }

        else if (IsAttacking == true)
        {
            IsMoving = false;
            forceDelta = new Vector2(0, 0);
            CalculateMovement(forceDelta * speed);
        }
        
    }

Hmm try adding a deadzone. A float of exactly 0 is hard to achieve so IsMoving might rarely be false; e.g if (horiz < 0.1~~ etc . GetAxis instead of raw may be better fitting. Also,

     if (attack_input > 0)
     {
         IsAttacking = true;
         IsMoving = false;
         Debug.Log("Attack State ACTIVATED");
     }

and,

     else if (IsAttacking == true)
     {
         //forceDelta = new Vector2(0, 0); <- Maybe you still need this
         rigidbody.velocity = Vector2.zero;
         Debug.Log("Stopped Rigidbody");
     }

Your movement should be based on the animation clip’s state of Play if you want to not move upon release but when Attack has finished. For example, access the Animator and determine when the Attack state is in Play or not and make IsMoving depend on that instead of whether or not the button is pressed.