Dash/Teleport move is inconsistent

Hi guys, having some issues with my dash ability.

With transform.Translate, it works perfectly. I lose 50 energy and the player dashes forward.

With rb.Velocity, sometimes when the move fires, the player does not actually dash forward (even though they lose energy).
This is the same with AddForce

The issue with Translate is that it teleports through walls

This is the below function:

 void PlayerDash()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift) && currentEnergy == 50 && dashUpgrade)
        {
            StartCoroutine(InvincibleTime());
            //float deltaSpeed = dashSpeed * Time.deltaTime;

            if (!concussionUpgrade)
            {
                //if no concussion, do normal dash
                if (facingPositive)
                {
                    //rb.AddForce(new Vector2(dashSpeed, 0), ForceMode2D.Impulse);
                    transform.Translate(Vector2.right * dashSpeed);
                    //rb.velocity = new Vector2(dashSpeed, 0);
                    currentEnergy -= 50;
                    print("Dash enabled");
                }
                else
                {
                    //rb.AddForce(new Vector2(-dashSpeed, 0), ForceMode2D.Impulse);
                    //rb.velocity = new Vector2(-dashSpeed, 0);
                    currentEnergy -= 50;
                    print("Dash enabled");
                    transform.Translate(Vector2.right * -dashSpeed);
                }

            }
            else
                //else do special dash routine, spawning concussion at place of origin, and new location
                StartCoroutine(ConcussionSpawn());
        }
    }

Any help would be greatly appreciated :slight_smile: thanks!

Are you calling this though update or fixed upsate?

When you do sruff to the physics system like changing velocity you better be in fixed update