- Home /
Question by
ogito123 · Sep 11, 2020 at 08:04 AM ·
controllercoroutinedash
3D characther controller dash ability with coroutine doesnt work
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;
}
Comment
Best Answer
Answer by ogito123 · Sep 11, 2020 at 08:15 AM
For future users, problem was fixes when I changed "yield return new WaitForSeconds(Time.deltaTime);" to "yield return new WaitForFixedUpdate();"
Your answer
![](https://koobas.hobune.stream/wayback/20220613011635im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A way to run code during WaitForSeconds? 1 Answer
2D dash in coroutine Inconsistent 1 Answer
Prioritizing Player Animations 0 Answers
Help with my Dash move? 1 Answer
How do I use controller knob input like mouse position? (New Input System) 1 Answer