Problem with "Every N Seconds" Behavior


  • Posts: 104
So I want to spawn shapes every few seconds, and have it spawn shapes faster as time goes on, to increase the difficulty. The variable, "Shape Spawn", starts out as 2.

This is the code to spawn shapes:

This is the code that increases the spawn rate:

So, theoretically, after 1 second, the spawning rate of the shapes should go from one shape every 2 seconds to 1 shape every 1 second. However, the spawning rate of the shapes stays the same. But, when I reload the scene, the spawn rate becomes 1 every second. This suggests that the "Every N Seconds" behavior won't update how fast it goes depending on what the variable is at the moment, only what the variable was at the start of the scene. Is there any way to solve this?
-Tetra Factory - 80%


  • *
  • Posts: 2469
"Do every" codes only take in a value ONCE, so whatever it is to begin with is what it will be. If you want the time to speed up, use a custom event with a "do after" time, which calls itself after that time is up. Even though "Do after" also only takes in the value once, each time around, it's doing the "do after" code freshly, so it will see the updated time.

If you go into the StencylForge, into the game section, and search for "Demo-", you will find my demo tutorials. Many of them use this idea (such as the spawning of enemies for "Demo- Upgradable Shooter" or the creation of platforms in either "Demo- Infinite Platformer" or "Demo- Infinite Climber"), so you can see it first-hand.
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (,16160.0.html)