Variable in Game Update Event not updating

Hi there,
I’m trying to decrease the time between enemies spawning by putting a variable in the
game update every event block.

Looking at debug the value is going down, but no increase in numbers of projectiles spawning. Any ideas?


We talked about this once or twice in our livestreams; at 14:41 in you can hear me fumbling through the explanation for this (it was my first time hosting the live stream so it was a bit extra awkward) - but the basic issue is just that the on game update is given an interval once, which is whatever spawnTime stores immediately after on start finishes. (I think we might change this in the future, so that it works in this sort of situation - it’s easy enough to fix, we just have to be sure its a thing we want to change and do it.).

The fix here is to use a forever loop, with a pause at the start or end that pauses for spawnTime. This value will be updated as it’s part of the body of the event, which is re run each time, and not the instantiation of the event, which is not.

1 Like

Great! Thanks for the clear explanation :slight_smile:
That makes total sense.

Here’s the revised project in case anyone wants to see this in practice.


1 Like

Thank you so much for this work around. But man… why on earth is this even a bug?

It is not a bug. As @jwunderl explains, the ‘game update interval’ event is registered with fixed interval.

Huh, I just had this problem and came looking for an answer – glad I found it, but I could have sworn the pause block was pausing my whole game when I tried using it in the past.