Dashing doesn't work

Hello, I made dashing in my game and when I made it, it worked just fine but now after few things I added into the game it still plays animation but it wont go forward.

Does anyone know why?

Could some other code break it?

I personaly dont think so because i checked every code in game and it didnt even mention anything with player movement.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using TMPro;
using UnityEngine;
using UnityEngine.Events;

public class PlayerMovement : MonoBehaviour
{
    public Animator animator;

    public Transform attackPoint;

    public GameObject popUpPrefab;

    public float attackRange = 0.5f;
    public int attackDamage = 40;
    public LayerMask enemyLayers;
    public int damage;

    public float attackRate = 3f;
    float nextAttackTime = 0f;

    private float horizontal;
    private float speed = 8f;
    private float jumpingPower = 32f;
    private bool isFacingRight = true;
    private bool inAir;

    private bool canDash = true;
    private bool isDashing;
    private float dashingPower = 150f;
    private float dashingTime = 0.2f;
    private float dashingCooldown = 1f;

    [SerializeField] private Rigidbody2D rb;
    [SerializeField] private Transform groundCheck;
    [SerializeField] private LayerMask groundLayer;
    [SerializeField] private TrailRenderer tr;

    void Update()
    {

        animator.SetBool("IsDashing", isDashing);
        animator.SetFloat("Speed", Mathf.Abs(horizontal));
        animator.SetBool("IsJumping", inAir);

        if (isDashing)
        {
            return;
        }

        if (Time.time >= nextAttackTime)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Attack();
                nextAttackTime = Time.time + 1f / attackRate;
            }
        }
        horizontal = Input.GetAxisRaw("Horizontal");

        if (Input.GetKeyDown(KeyCode.W) && IsGrounded())
        {
            inAir = true;
            rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
        }

        if (Input.GetKeyDown(KeyCode.W) && rb.velocity.y > 0f)
        {
            inAir = false;
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
        }

        if (Input.GetKeyDown(KeyCode.LeftShift) && canDash)
        {
            StartCoroutine(Dash());
        }

        Flip();
    }

    void Attack()
    {
        animator.SetTrigger("Attack");

        Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers);

        foreach (Collider2D enemy in hitEnemies)
        {
            GameObject popUp = Instantiate(popUpPrefab, attackPoint.position, Quaternion.identity);
            popUp.GetComponentInChildren<TMP_Text>().text = attackDamage.ToString();
            enemy.GetComponent<BansheeHealth>().TakeDamage(attackDamage);
        }
    }

    private void FixedUpdate()
    {
            rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
        
        if (isDashing)
        {
            return;
        }

    }

    private bool IsGrounded()
    {
        return Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
    }

    private void Flip()
    {
        if (isFacingRight && horizontal < 0f || !isFacingRight && horizontal > 0f)
        {
            isFacingRight = !isFacingRight;
            Vector3 localScale = transform.localScale;
            localScale.x *= -1f;
            transform.localScale = localScale;
        }
    }

    private IEnumerator Dash()
    {
        canDash = false;
        isDashing = true;
        float originalGravity = rb.gravityScale;
        rb.gravityScale = 0f;
        rb.velocity = new Vector2(transform.localScale.x * dashingPower, 0f);
        tr.emitting = true;
        yield return new WaitForSeconds(dashingTime);
        tr.emitting = false;
        rb.gravityScale = originalGravity;
        isDashing = false;
        yield return new WaitForSeconds(dashingCooldown);
        canDash = true;
    }
    void OnDrawGizmosSelected()
    {
        if (attackPoint == null)
            return;

        Gizmos.DrawWireSphere(attackPoint.position, attackRange);
    }
}

Did you mess up your FixedUpdate? You have posted this:

private void FixedUpdate()
{
    rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
    
    if (isDashing)
    {
        return;
    }

}

Which is nonsensical - it says “Set the velocity to the input”, and then “if dashing, return”, but you always set the velocity, so you’re going to override the velocity from the Dash coroutine, and the if-return doesn’t do anything at all.

I assume you want:

private void FixedUpdate()
{
    if (isDashing)
    {
        return;
    }

    rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
}

Or, much cleaner:

private void FixedUpdate()
{
    if (!isDashing)
        rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
}