Need help understanding advise

Hi everyone! I hope this will make sense.

I am trying to make a 2d character controller and i’ve already implemented basic 2d movement using “GetAxisRaw” and “rb.velocity = new Vector2 (moveInput * moveSpeed, rb.velocity.y);”

Now I am trying to add a dash feature like in Hollow Knight, and I found a great tutorial by Blackthornprod and he’s doing it with “rb.velocity = Vector2.left/right * dashSpeed;”. But this doesnt work for me and someone in the comments wrote “you are probably changing velocity of the rigidbody in your normal movement as well. make sure you are running this script after your movement script takes place so that this one takes control.”, which I think is correct but I have no idea how to fix this. Unfortunately he’s not answering so here we are.

What should I do? any help is much appreciated!

You could use a bool with if statements.

if(dash){
    rb.velocity = Vector2.left/right * dashSpeed;
}
else{
    rb.velocity = Vector2.left/right;
}

Or set dashSpeed to an amount and have it -= by a deceleration value.

rb.velocity = Vector2.left/right * dashSpeed;
dashSpeed -= Time.deltaTime;
dashSpeed = Mathf.Clamp(dashSpeed, 1, //dash amount)