Spawn actor to all spawnpoint

Hi i’m new in blueprint and for now my function spawn a ball to only one spawnpoint, but i’d like to do it for ALL spawnpoint in the map how would you do it? p.s i have a timer that will spawn every 2 second.

I see what you what to say but its my first time with UE4 and… i dont know what node and how to construct it :’(

You need an array of the spawn points, then do a “for each” loop on the array, and spawn a ball at each instance of the spawn points in the loop body.

i see but my problem is the number of waypoint isnt static does it work the same way? and its a function not a event graph (im doing a school project and I need to do it in the function i showed earlier they said i can do it before the get)

I added references to all of the waypoints in the level, then I made an array of them, then I did a for each loop on that array and spawned (in this case an enemy), at each of the locations of the waypoints in the level. (The waypoints I used are just a target point actor).

Hope that helps!

So in your example, grab the “Out Actors” and then create a new “For Each” node and make the Out Actors go into the For Each node. Then connect the For Out Actors node to the For Each node, and then connect the Loop Body to the stuff you want to spawn.

like that?

Sort of. it’s getting close. Where it says Array Element, drag off from there and connect it to the Target of the Get Actor Location node.

Then Connect the Return Node to the Completed output on the For Each Loop (Otherwise it’s going to return after spawning just 1).

Then you can delete that “Get” node.

thanks very much it worked (like every 2 second a ball was spawning) but my teamates want to make that it cant spawn at the same place any idea? this is curently my function and for now only one ball spawn

yea well let say i have 5 spawnpoint the ball will spawn at 1 to 5, next 2 second it will be 1 to 4. till all spot are used, with the picture above its spawn but sometime they are 2 ball at the same place

So you want a ball to spawn at a different place each time? You’d need to cycle to the “next” spawn point each time the ball spawns. You need an index tracker variable so that each time you spawn a ball, you spawn it at the next index of the spawn point array.

You’d need a ball manager system. I’m not sure when your function above gets called. Is it being called every 2 seconds? What’s the condition that you’re using to determine when the function is called?

And you only want it to spawn balls at empty spawn points?

the function is called when i hit play, and every 2 second (for now its a variable) its spawn a ball

Yes until they are all filled

yea it have to stop :frowning:

yea but its a school project and my teammates (that are way better than me -.- ) said i have to do it in my function like shown before, for now the only thing that it need is to not spawn a ball where a ball is already is and stop when no place left

But this function fires every 2 seconds. So what’s going to happen when all of the spawn points are filled?

So once you’ve iterated through each spawn point, you need to clear the timer. However, this would probably be cleaner and more straightforward to set up in the event graph rather than have 2 separate functions handling this. You can use a delay in the event graphs, where you cannot use a delay in functions. It would be a pretty simple loop if you did it in the event graph.