ForLoop not firing correctly

So I am using a box collision component inside a blueprint to get all overlapping actors when this rail gun is fired, then running a ForLoop (or ForEachLoop, neither is currently working) on all overlapping actors to spawn an explosion and deal damage. But, while the get overlapping actors node is returning all the overlapping actors (12 here) using that result in either a ForLoop or ForEachLoop is only firing 6 times. As you can see in the blueprint, I’m getting the length of the array and printing that result, 12, the first number printed in the screenshot, then immediately plugging that value into a ForLoop and printing the index each time it fires, which is 6 times.

Does anyone know what the heck is going on here? Am I missing something obvious?

Manually entering 12 in the ForLoop makes it work on all 12 guys, so I have no idea why plugging in the length wouldn’t work.

The only thing that stands out to me is that you are using a class filter on the get overlapping actors. If all the actors are not of that class, then those that are not of class Zombie1Character, will not be returned.

Beyond that, can’t really see anything wrong, as there is not much going on in the blueprint.

It would be interesting to see if you get 7, or still the same 6, if you change the start index for the For Loop to 0 (zero). It would also be nice to see what the name of objects are that are being returned, or if there are null entries in the array. As well as the output log for a run of this.

Looks like I just fixed the problem by making an actor array variable and saving the overlapping actors to that, then using that variable in the ForEachLoop. Still doesn’t make sense though why I can’t use the direct result of the get all overlapping actors node.

All the actors are the same and of that class, plus the overlapping actors node is already returning the correct number so it is reading them all.

Just tested that.Changing start index to 0 gets 7 results, 0-6. Printing the Array Element from the ForEachLoop when that is firing returns AI_Zombie_Character for every entry. Zombie1Character is the parent class for that actor.

Joe,

Did you happen to check the output log, to see if there were any messages being displayed from the runtime of the virtual machine for blueprints? That might give the information your looking for. Although that would be more usefully done with the for each loop.

Null entries in arrays, will at times give blueprints, erratic behavior.