Dude(s), you don't need to run your timers like that. If you look at my example again, you can see that the first timer sets off the second function, and that function adds a timer to call
itself, not the previous function again, and will keep calling itself, that way you keep all your code to 1 function rather than switching between them constantly (which is delaying you're loop)
Rewrote your code to demonstrate
void TurnAround(string &in asTimer)
{
[...]
AddTimer("Start", 0.5f, "RepeatWalking");
AddTimer("", 1.5f, "StopEverything");
}
void RepeatWalking(string &in asTimer)
{
MovePlayerForward(5.0f);
AddTimer("Repeat", 0.01f, "RepeatWalking");
}
void StopEverything(string &in asTimer)
{
[...]
RemoveTimer("Repeat");
}
Hope that clears things up. Nice work on finding that solution
JAP, there's a different problem with the code you wrote,
void StartWalking(string &in asTimer)
{
MovePlayerForward(5.0f);
AddTimer("", 0.01f, "RepeatWalking");
}
void RepeatWalking(string &in asTimer)
{
AddTimer("RepeatWalk", 0.01f, "StartWalking");
AddTimer("", 3.0f, "StopWalking");
}
If you think about this, RepeatWalking is going to get called roughly 300 times before the first call to StopWalking.
This means that 300 timers are being declared that will all call StopWalking, which means another 300 timers are getting set up to call GiveControlBack.
The code in those functions won't run into any problems due to being called so many times, but I thought I would point out the issue for you in case you do this again in the future with code that will cause problems