- Home /
CharacterController.move is jerky in coroutine
Thanks to Bunny83 and Bérenger Mantoue, I'm using a coUpdate every 0.1 seconds to control my AI script, which has boosted my performance brilliantly. Unfortunately, my zombies (with CharacterController attached) now jerk forward, as the move command is only being called every o.1 seconds. Am I missing something?
the relevant code is:
function Start()
{
CoUpdate();
}
function CoUpdate()
{
while(true)
{
controller.Move(forward * Time.deltaTime * speed);
yield new WaitForSeconds(0.1);
}
}
Any way I can get them moving forward smoothly again please? Any help appreciated. Cheers Ian
Answer by husbandofemily · Jan 29, 2013 at 02:13 PM
Must've been tired, I got it first thing this morning! In case anyone else comes across this,I just added an exposed boolean variable, and turned this on and off when the character should be moving. Add in a normal function Update() with an if(newVariable) statement, and put the characterController.move in there. Sorted!