I am trying to write a coroutine that dashes my player forward. It works very fidgety, like it moves a bit really fast, then stops, then repeats the process again until the dash is over. I’ve printed the part of the code I think is necessary below.
public override IEnumerator Cast()
{
canCast = false;
controls.canMove = false;
float curTimeLeft=dashDuration;
while (curTimeLeft >0)
{
Vector3 dasher = transform.forward * dashSpeed*Time.deltaTime;
controls.cc.Move(dasher);
curTimeLeft -= Time.deltaTime;
yield return new WaitForSeconds(Time.deltaTime);
}
controls.canMove = true;
yield return new WaitForSeconds(cooldown-dashDuration);
canCast = true;
}