Hello, I am trying to do a 2D dash effect. I am using a coroutine to do it. The problem is that the distance the player travels is inconsistent. Its close but not fully accurate. How can I fix it? The necessary sample of the code is below. Thank you.
Physics usually run on the FixedUpdate cycle which is more or less independent from the framerate and the Update cycle. WaitForSeconds can only wait approximately for the given time. Since it can only continue after a full frame the time could always be slightly more than what you have specified. Instead of
Of course since you set your velocity only once at the beginning of your dash, it’s possible that due to collisions or friction you loose momentum. Maybe you want to set the velocity every frame during the dash?