How can I implement delay into my project?
I'm so lost in timers and delegates.. I can't find a clear description on how to use timers, specially the GetWorldTimerManager().SetTimer(....) function and what the arguments inside it refer to or how they are related to each other.
I'm trying to accomplish a simple delay between spawning Actors. In my BeginPlay() function, I have a loop from 0 to 8, inside the loop body it spawns a new actor that is stored in an array (i.e myActor to myActor). I just want to add a delay after each actor is spawned so that not all the actors get spawned at the same time.
-Where do I implement the GetWorldTimerManager().SetTimer(...)
-What are the arguments inside SetTimer(...)
-Does SetTimer() provide delay? How?
-Do I need to create my own Delay function outside BeginPlay()? How does it relate to SetTimer()?
It seems like you are setting a new timer every time you spawn a cell, and that timer will after one second spawn the actors again.
Instead you need spawn cell to spawn one actor and then set a timer and when the timer executes SpawnCell it will create the next actor, working through the loop one step at a time.
Maybe something like this?
You'll want to do something like:
This will call spawn actor after one second. You can also add a 'true' parameter after your 'time to wait' variable that will loop the call as well.
Therefore, you could create a recursive function for a simple approach:
with SpawnActor being a void with no parameters -- void SpawnActor(); -- Obviously, you can get a lot more in-depth with the timing methods, but this is a simplistic approach which should suit your needs hopefully?
answered Sep 16 '14 at 09:47 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here