Spawning random number of enemies at the same time on location
I'd like to know how to spawn a random number of enemies (Like between 1 to 4) at a spawner. I'm able to spawn enemy one by one, but can't figure out how to spawn multiple enemies at the same time.
I'm using this tutorial form UE Youtube Channel : https://www.youtube.com/watch?v=4SKY_wfHN1g
So, here are my Blueprints : Gamemode : https://i37.servimg.com/u/f37/11/08/58/06/gamemo10.png Spawner : https://i37.servimg.com/u/f37/11/08/58/06/spawne10.png
asked Jan 11 '17 at 09:06 PM in Blueprint Scripting
Since computers are not capable of doing more than one thing at a time, you are going to have to use some kind of trick to make it appear like they are all spawned at the same time. The spawning code is a bit slow (but not that slow), so if you absolutely need all of them to appear at exactly the same instant, I would spawn them hidden and then when they are done spawning, make them all visible at once.
I looked at your blueprints and I am a bit confused by the first one. Personally I think there is never a reason to use the Tick event. So I would move the code you have in the Tick even to the Begin Play event or whatever other event might be the trigger for the spawning to start. The Set Timer by Function Name looks good and is my preferred method to get around not using the Tick event.
The other thing that is confusing is that I see you are trying to spawn more than one enemy, but I don't see a For Loop. I think you want to add a For Loop to your SpawnEnemy that loops the number of times of enemies you want to spawn (pass in the number of enemies as a parameter to determine how many times to loop). I think if you add a For Loop to the SpawnEnemy they will stop spawning one at a time and you won't even need to start with them hidden.
answered Jan 11 '17 at 10:34 PM
Hi, thank you for your answer !
I followed your instructions and... It works pretty well !
Now, about the Tick Event, why do I use it ? Because if I use Event Begin Play, the event is going to be fired only one time and only one. Which means enemies are going to spawn at one spot only and it won't change through the game is runing.
If I use Event tick, every 2 seconds ( For example with my delay ), my enemy spawn is going to change every 2 seconds.
answered Jan 12 '17 at 09:54 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here