Why is my timer loop working only for about 60 seconds?

Hi, I’m trying to do some simple spawning in the world at different locations. The spawning logic is working but the set timer loop is looping only for 30 times if I set it to iterate over 1 second, and only 15 times if i set it to 2 seconds. What could be causing that to happen? Blueprint below.

Thanks.

When you increase the timer interval to 1 second, you get around 30 iterations, and with 2 seconds, around 15 iterations. This indicates that there is a fixed total time (~30 seconds) after which the timer’s owner is destroyed — and when the actor that owns the timer is destroyed, the timer stops as well.

In your second image, you can see the Set LifeSpan node connected to the return value of SpawnActor. This means you’re assigning a lifespan (probably 30 seconds) to the spawned actors. If the timer is running on the same actor (or belongs to it), it will be interrupted when that actor is destroyed. That’s why with a 1-second interval you get ~30 loops, and with 2 seconds you get ~15: 30s / 1s = 30; 30s / 2s = 15.

Try setting the timer in the Level Blueprint, GameMode, or in an Actor/Manager that isn’t destroyed. This way, the timer won’t be interrupted when the spawned actors disappear.

In summary… your Set LifeSpan node is destroying the actors after X seconds (apparently 30s), and the timer is stopping when the actor dies. Move the timer to a persistent owner (LevelBP/GameMode/Manager), or increase/remove the lifespan to fix the issue.

Check you skyandstuff bp class defaults if you didn’t accidentally change the lifespan parameter there. If initial life span is set to anything other than zero then the spawner will be destroyed after that time passes.

From the code itself I can get passed 30 loops with no problems.

I would also suggest not using lifespan as a variable name as it may conflict with the internal variable of actors in the engine. Just like not naming a project anything like test.

MasterLifespan or LifeSpanOverride could be ok options.