Preventing movement input during animation (Dash)

I’m prototyping in Unity2D as a beginner, and I got the top-down movement working, as well as a basic attack. However, I’m trying to implement a Dash&Attack when the player presses the run button and the attack button, so the player character speeds up, moves a few units, and returns to regular speed.

I’d like to lock the player so the character executes the dash in the facing direction when initiated, without being able to change direction based on input (or have a shorter dash); however, input is still being processed, even though I’ve tried many conditions to prevent that.

My Movement Controller is on a separate script from the Combat Controller (which deals with basic attack and Dash & Slash logic). Here are some code excerpts:

 private void Update()
 {
         GatherInput();
     
 }

private void GatherInput()
{
        _moveDirection.x = Input.GetAxisRaw("Horizontal");
        _moveDirection.y = Input.GetAxisRaw("Vertical");
        _isRunning = Input.GetButton("Run");
}

private void FixedUpdate()
    {
        UpdateAnimations();

    }

private void UpdateAnimations()
{
    if (_moveDirection != Vector2.zero)
    {
        _pc_Animator.SetBool("isMoving", true);
        MovementUpdate();

    }
    else{
        _pc_Animator.SetBool("isMoving", false);
        _pc_Animator.SetBool("canMove", false);
    }

    if(Time.time > timeToBlink)
    {
        doBlinkRoutine = DoBlink();

        StartCoroutine(doBlinkRoutine);
    }

}

private void MovementUpdate()
{

    _moveDirection = new Vector2(_moveDirection.x,_moveDirection.y).normalized;
    facingDirection = _moveDirection;

    if (canMove)
    {

        if (!_isRunning)
        {

            _pc_RB.MovePosition(_pc_RB.position + _moveDirection * _moveSpeed * Time.fixedDeltaTime);
            _pc_DirtAnimator.SetBool("isRunning", false);

        }
        else
        {
            
            _pc_RB.MovePosition(_pc_RB.position + _moveDirection * _moveSpeed * _runningSpeedMultiplier * Time.fixedDeltaTime);

                _pc_DirtAnimator.SetBool("isRunning", true);

            }
            

        }

        _pc_Animator.SetBool("canMove", canMove);
        _pc_Animator.SetFloat("moveX", _moveDirection.x);
        _pc_Animator.SetFloat("moveY", _moveDirection.y);

    }
    else
    {
        //_pc_RB.MovePosition(_pc_RB.position);
    }

}

And here’s the logic for Dash and Slash:

private void Update()
{
    
    CheckCombatInput();
    CheckAttack();

}

private void FixedUpdate()
{
    RunSlashMovement();
}

private void CheckCombatInput()
{

    if (combatEnabled)
    {

        if (Input.GetButtonDown("Attack"))
        {
            //Atack
            gotAttackInput = true;
            lastInputTime = Time.time;
        }
        if (Input.GetButton("Run") && Input.GetButtonDown("Attack") && _pcController.GetMoveDirection() != Vector2.zero)
        {
            //Run & Slash
            gotAttackInput = true;
            lastInputTime = Time.time;
            isRun_Slash = true;
        } 


    }


}

private void CheckAttack()
    {
        if(gotAttackInput)
        {
            
            if(!isAttacking && !isRun_Slash)
            {
            
                gotAttackInput = false;
                isAttacking = true;
            
                //Do Anim stuff
                _pc_Animator.SetBool("isAttacking", isAttacking);

                //Sword Trail
                _pcSwordTrailTransform.position = attackHitBoxPos.position + (facingDirectionIn3D * 0.5f);

                _pcSwordAnim.SetBool("isAttacking", isAttacking);
                _pcSwordAnim.SetFloat("posX", facingDirectionIn3D.x);
                _pcSwordAnim.SetFloat("posY", facingDirectionIn3D.y);

                //Play Sound
                PlaySwordAttackSFX();
   


            } else if (isRun_Slash) {

                if (Time.time >= runSlashCooldown) 
                { 
                    gotAttackInput = false;

                    //Do Anim stuff
                    //_moveDirection = _pcController.GetMoveDirection();


                    _pc_Animator.SetBool("isRun&Slash", isRun_Slash);
                    _pcSwordAnim.SetBool("isRun&Slash", isRun_Slash);
                    _pcSwordAnim.SetFloat("posX", facingDirectionIn3D.x);
                    _pcSwordAnim.SetFloat("posY", facingDirectionIn3D.y);


                    //PLAY SOUND FX
                    PlaySwordAttackSFX();

                    runSlashCooldown = Time.time + 1f;


                }

            }

        }
        if (Time.time >= lastInputTime + inputTimer)
        {
            gotAttackInput = false;


        }
        
    }

private void RunSlashMovement()
{
    if (isRun_Slash) { 
        _pcRB.MovePosition(_pcRB.position + new Vector2(_pcController.GetMoveDirection().x, _pcController.GetMoveDirection().y) * 3.25f * _pcController._moveSpeed * Time.fixedDeltaTime);
    }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật