FTimerManager::SetTimer

Hi…

I am using the timer function to spawn enemy characters in my game world. I used the same method that was used in the battery collector tutorial. This is the line that sets the timer:
GetWorldTimerManager().SetTimer(spawnTimer, this, &ASpawner::spawnEnemy, spawnDelay, false);

My question was really around the bool parameter for looping. This is what is in the api docs:

InbLoop true to keep firing at Rate
intervals, false to fire only once.

I’m not sure, looping of what does this parameter controls…

I’ve tried both ‘true’ and ‘false’ values here but there seems to be no visible difference in the way the enemy spawns in the game!!

Would appriciate any explanation.

Thanks,

What they mean by “looping” is if the value is true, the “timer” will “fire” (or call the routine), at X interval forever, if the timer is false, then the timer will only “fire” (or call) one time. You actually shouldn’t any difference visibly in the enemies you are spawning, as hte timer has nothing to do with this, nor does it care. That will be ASpawner’s job.

The biggest difference you will see, is that if it’s set to False, then the enemy will only spawn one time, as there is only one call. If it’s set to true, then the timer will call, and if ASpawner is doing it’s job blindly (i.e. not keep track of the number of enemies spawned versus killed, etc), then it will spawn another enemy, just like it did the first time.

Hope this helps!

.

Ok cool. I was thrown off a bit because in the battery collector example the pickups were being spawned continously and hence in the game that i was working even with the value of ‘false’ and this was because the timer is being set once in beginPlay and then later in the last line of the called function, which made sure it was called again later.

In my project i tested by commenting the call to setTimer at the end of function and just using the call in beginPlay, once with ‘true’ and then with ‘false’ and now i can clearly see the difference in behaviour.
Thanks…

More than welcome!

Have a great day!

.