Bug: Only destroys one per loop

Hi.
Might have found a bug.

I spawn several BP_Wall. It cointains wall mesh, and box overlap all with standard collisions.
Afterwards i spawn BP_Door. It contains another wall mesh, and a box overlap all with standard collisions.

Upon spawn of BP_Door, i have a custom event triggered.

BP_Door(Box → Get Overlapping Actors(Filter Out BP_Wall)) set in a For Each Loop → Destroy actors (Exec comes from Loop Body, and Target is linked in Array Element)

When this runs, only one BP_Wall is removed (2 is overlapping)
but if i before the For Each Loop, runs a ForLoop from 0 to 1, it removes both Walls.

I had this same problem. You MUST save the output of Get Overlapping Actors into a new array and then loop through that new array if you want deterministic results. The foreach actually grabs a new array from a new Get Overlapping Actors call each time through the loop, but increments through the index as if the array were the same as the one it started with.

Nice!
Thank you for the reply :slight_smile:

Glad I could help! Please “accept” this answer if this fixed the issue. I’m working on a forum badge for being helpful in AnswerHub. :wink: