Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move Player / Remove Timers
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#11
RE: Move Player / Remove Timers

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

(This post was last modified: 05-22-2013, 01:03 PM by Adrianis.)
05-22-2013, 01:03 PM
Find


Messages In This Thread
Move Player / Remove Timers - by Shirder - 05-20-2013, 06:10 PM
RE: Move Player - by Slanderous - 05-20-2013, 06:29 PM
RE: Move Player - by OriginalUsername - 05-20-2013, 06:35 PM
RE: Move Player - by Adrianis - 05-20-2013, 07:08 PM
RE: Move Player - by Shirder - 05-20-2013, 08:41 PM
RE: Move Player - by Adrianis - 05-21-2013, 02:45 AM
RE: Move Player - by PutraenusAlivius - 05-21-2013, 02:43 AM
RE: Move Player - by Shirder - 05-21-2013, 10:20 PM
RE: Move Player / Remove Timers - by Shirder - 05-22-2013, 11:33 AM
RE: Move Player / Remove Timers - by Adrianis - 05-22-2013, 01:03 PM



Users browsing this thread: 1 Guest(s)