30 on 30 off loop

BrundiBrundi Member Posts: 60

Hi, I hope this doesn't get to complicated and someone can help me with this. I want to make a game where for thirty seconds every one second it spawns an actor. After the thirty seconds are done I want there to be a thirty second pause where nothing is spawned for 30 seconds. After that I want it yo loop again and spawn for 30 seconds and wait for 30 seconds ect. I have tried to accomplish this with timers and a Boolean attribute but I can't seem to get it to work

Thanks thanks thanks, Brandon

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    @Brundi said:

    No real need for attributes of any kind - just compound a few timers in the right order . . . .

    Timer: Every 60 seconds

    Timer: For 30 seconds

    Timer: Every 1 seconds

    Spawn: The thing you want to spawn.

    . . . . .

    A confusion often arises with timers, in that people expect an 'every' timer to produce a result instantly - and then one again at X seconds later (X being whatever time - in seconds - you have you timer set to) - and so on . . . . but an 'every' timer doesn't do anything until X seconds have elapsed . . . so in a situation like the above, you would want to place a spawn behaviour outside of the timers - as well as one inside, the outside one does the initial spawn (at 0 seconds) and the one inside handles everything else from there onwards.

    This initial pause (especially on long timers like 30 seconds) can make people think their code is not working when it's doing exactly what it should be doing (waiting 30 seconds).

    So to take into account this initial - one off spawn - the logic should look like this:

    Timer: For 30 seconds

    Timer: Every 1 seconds

    Spawn: The thing you want to spawn.


    . . . then . . . .

    Timer: Every 60 seconds

    Timer: For 30 seconds

    Timer: Every 1 seconds

    Spawn: The thing you want to spawn.

    I'll make you a quick demo . . . . back soon . . .

  • SocksSocks London, UK.Member Posts: 12,822
  • BrundiBrundi Member Posts: 60

    Woah, Thanks a ton. I didn't expect these forums to be so helpful. You really helped me out socks! Thanks!

Sign In or Register to comment.