Dash Going Up Instead of Horizontal

Hey! Currently working on my game but for some reason every time I press E (activating the dash) All it does is keeps me hovering.

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

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

[SerializeField] private Rigidbody2D rb;
   

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

   if(Input.GetKey(KeyCode.E)) {
        StartCoroutine(Dash());
        Debug.Log("dash");
    }
}

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

   
}



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

private IEnumerator Dash()
{
    Debug.Log("dashing");
    canDash = false;
    isDashing = true;
    float originalGravity = rb.gravityScale;
    rb.gravityScale = 0f;
   
   
    yield return new WaitForSeconds(dashingTime);
   
    rb.gravityScale = originalGravity;
    isDashing = false;
    yield return new WaitForSeconds(dashingCooldown);
    canDash = true;
}


This is a platformer.

Keeps you in a hover sounds about right for turning off gravity.

What did you actually want to happen for a Dash()?

Sounds like you wrote a bug… and that means… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

where is your actual dash logic? All i see is you changing the rigidbody’s gravity scale. You need to apply force or velocity to your player to actually dash. Also you can flip 2d characters by flipping their spriterenderer. Its just a one line code.

m_spriteRenderer.flipX = true;

for vertical just do flipY = true