Every X Seconds + Restart Layout

0 favourites
  • 13 posts
From the Asset Store
Like tourists, Travel around the world as fast as you can!
  • I have the following issue:

    The "every x seconds" command does not seem to reset, if I restart the layout.

    I have an object, which is created after every 2.5 Seconds. So if I restart the layout, sometimes two instances of this object are generated on top of each other.

    Is there a way to reset the after "every x seconds" command?

    Thanks in advance.

  • Every X seconds is based on the system timer, not the running time of a layout.

    It would be better to either use the Timer behavior or create your own timer by creating a global variable and adding dt to it every tick. Then you can reset it to 0 when you want.

  • Okay I also considered the variable on every tick solution. But I thought it whould be more demanding than the every x seconds command.

    So I will try the timer behavior. Thank you.


    Thanks it works like a charm.

  • Hi guys, I know this is an older post, but it is my exact problem and I don't really understand the solution. I get the idea of the Timer behavior or using a delta timer Global Variable, but I don't just don't get how to implement it. The Timer behavior is related to an object and right now it is the System spwning my objects so I don't quite get that part. As for my own Timer, where/how do I actually make the repeatable counter.

    My problem is that right now the System is creating the objects for me and from what I under the object itself needs to create... itself?


  • you can create an event "every X seconds", and just as it states, every x seconds it will trigger and start counting again. so in the case of a spawner, that should work,

    the problem Alyra had, was that he was restarting the layout and the "every X command" is not meant for that use.

  • Thanks for your quick reply! Actually I'm having this problem. My spawners are set at Time >= 4 sec then every 3 seconds spawn. The problem is that when I restart the layout for a new game it does not wait and they immediately start spawning things!

  • that is because when you restart the layout, the game has already been playing for several seconds.

    You need to make a custom timer.

    1) make a timer variable and set it to a value (like 240)

    2)every tick, while timer variable es greater than 0, substract 1 (60 ticks in a seconds, so it should take 4 seconds to subtract all 240)

    3)when timer variable is equal to 0 = spawn every 3 seconds.

    4) enjoy.

  • yeah using a timer is your best option... you can start and restart them whenever you want... makes things a lot easier...

    just make an empty game object, make it invisible and give it the Timer Behavior.

  • Ahhhh! Thanks a lot Sargas, that does make a lot more sense now! So I should just create a Text Object with a Timer and use that to control my stuff. Since I have multiple different timers, should I use a different one for every "Every x" and "Time =" events? What's the performance impact if that's not too much to ask?

  • nono, what i meant was that you

    1) make a Global Variable called "timer" or wathever, which you set to 240

    2) then you tell the system to subtract 1 every 1*st (60*dt = 1 second) while "timer" is greater than 0 (this event has 2 conditions)

    3) and when "timer" is less or equal than 0; set the variable back to 240. so the timer loops. and also do what you want to do at this point. (I recommend that you add a "trigger once while true" to this event")

    so, you don't really need to create any invisible objects for this, get used to the global variables. unless you need to have distinctive timers for different instances of the same object, in which case give the timer variable to the object instance variables.

    then, if you need to display the "timer"'s value, you set the text to ("text"&timer) <--- the word "timer" refers to the variable "timer"

    you could, in fact, make the variables inside the text object, but personally, i prefer to have variables like that in plain sight in the event sheet.

    however... i'm sensing that you want the system to start spawning things after a certain amount of time has elapsed since the start of the layout? you can create a variable timer for that too =P

    and in that case, use what i told you before, except don't restart that timer.

    and in the following events you can use the "every x seconds" along with the "variable = 0" condition. So the every X seconds will only become active after the first variable is done. And it will reset every time you restart the layout.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The forum has online sorry about the delay! I just really wanted to thank you! I didn't have to use the TImer behaviour and just use my own general dt timer for the whole game and even keep my "Every x" seconds. Thanks so much!!

  • technofou no problem!

  • Every X seconds is based on the system timer, not the running time of a layout.

    Stuff like this should really be in the documentation.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)