Velocity not changing throught IEnumerator

When I run this script every line works, except these which changes velocity. I don’t know how to fix it

    IEnumerator Dash()
    {
        Debug.Log("Dash");
        
        dashing = true;
        rb.velocity = new Vector2(xMov * dashPower, yMov * dashPower);
        yield return new WaitForSeconds(0.5f);
        rb.velocity = new Vector2(0, 0);
        dashing = false;  
    }

Are you still setting the velocity in the Update()/ FixedUpdate() method(s)?

If so you need to not do that, probably based on your dashing bool.

If that’s not it, well…

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.

https://docs.unity3d.com/Manual/ManagedCodeDebugging.html

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.

Velocity is being changed in update, but it’s controled by bool and it should be blocked. I tried to debug, debugged velocity, input axis, bools. I placed debug.log in different lines of this coroutine and always worked, every line was executed, only velocity ones not

What does that mean? Of course the lines would work. Have you printed the velocity before and after the assignment line inside the coroutine? You probably have some other code that may still mess with the velocity directly or indirectly. Indirectly may inlucde AddForce calls, rigidbody.drag or collisions. Maybe start showing your code that you have in Update. Did you actually place Debug.Log statements in the relevant parts in Update to see if the code you said would be protected by a bool actually isn’t running during the coroutine?

Is that Update method you were talking about part of the very same script? Or is it in another script?

Ok, I solved it by myself