How to create a working ForLoop

Hi there, I’m trying to create a ForLoop so that I spawn a set amount of slugs (7) in a set radius of the character.


I’m trying to create it so that there are always 7 slugs in the set radius, so I also created this in the tick

However, these two combined only spawn 7 slugs at the start then display how many slugs are there without keeping a steady number.

I think I need to somehow alert the ForLoop to check the number again, however when I tried plugging it into to tick event, well… I spawned over 100.

Any help in this matter is greatly appreciated, Thanks to anyone for replying.

P.S. This is all in the GameModeBP as it’s an open world one-map game

In the first diagram shouldn’t you be incrementing the number of slugs in the vicinity once the spawn is true?

Why not set the sphere overlap actors to class filter of type slug?

What is triggering the loop in the first diagram? Is it a custom event? Once the for loop ends it will not restart on it’s own accord.

Fixed it myself by tinkering for a little bit, this fix does work properly however I’m not sure if it’s the most efficient. If anyone comes up with a better or different solution are welcome to answer and I’ll mark their response as a solution respectively.


Here is the final product for anyone wondering.

  1. that’s what’s going on, if the success is true it ends and goes to “completed” if it’s false it repeats to try and get it right the second time if the random generation went wrong somewhere
  2. Yes, right now it detects all pawns but I’m working on that now.
  3. It goes to BeginPlay

Stay away from tick. Better to convert that to a function and setup Set Timer by Function Name set to looped and set like a 5 second interval for tests.

The most optimal way would be to bind an event dispatcher to the bug (if they are only around the player in the form of familiars) and bind that dispatcher to the player. Then on the bug death you could call the dispatcher so that the player knows a slug has died.

1 Like