How do i set up While loop to continue to spawn AI

Hey i am needing some help in getting the AI bots to spawn and keep spawning until they reach a certain about let’s say 10 and then stop spawning, i am doing this in hopes to make a wave game where i can set the amount to swap each wave, but i am taking it step by step just so i can understand and learn, would anybody be able to help me making it look so on a certain number spawn

Many thanks Alex :slight_smile:

##WhileLoop
You can do that by using the WhileLoop node.

WhileLoop Example

In this example I made two variables MaxSpawn and SpawnIndex. MaxSpawn is how many actors will be spawned in this while loop. Just change the value of MaxSpawn to change the amount to spawn. SpawnIndex is a variable used to compare against MaxSpawn and incremented every time.

I would recommend creating a function called something similar to SpawnWave and have MaxSpawn as a parameter and SpawnIndex as a local variable within the function.

##ForLoop
edit:
Looks like I got caught up on your title saying “while loop”. In this situation you could easily use the ForLoop node. Here’s a more simplified example of the above.

ForLoop Example

@ Saucy Thank you so much i will try it as soon as i can :slight_smile: Best thing about this community is that they actually help and i am so grateful for it!

This worked quite well thank you, the spawn AI from class did not work for me, the AI had no movement and did not act but i sorted it out with my first method :slight_smile: just one thing though, when i kill the AI they seems to want to automatically spawn at the player spawns is there a way i can stop that?

Hmm I can’t exactly tell from what you said, maybe if you posted screen shots of your blueprint I could help you. If you’re still having an issue maybe make another question specific to that one. I would recommend just playing around with the blueprints a lot. Try searching for new nodes with the right click dialog and using them.

How did you get the simple move to location. to move more then 1 (bot) i have the same layout on my blueprint it works great for spawning the number of bots i want. But will only move 1 out of 5