Actors don't disappear after "destroy actor"

The coding not pictured spawns boxes. Once there are 20 boxes, I want one big box to spawn and the 20 boxes to disappear because I think the game would run smoother since 1-10 “box replacers” are spawned instead of 20-200 boxes. At the moment, the box replacer spawns, but the other 20 boxes aren’t destroyed. What am I doing wrong?

In your ForEachLoop, your branch checks if the current index’ BP Box Master actor has the same Z as the BP Box Replacer you just spawned before destroying it. Are you just trying to destroy the BP Box Master actors in a certain location or all of them?

I am trying to destroy all actors below or equal to its world height

Are you sure the loop is running 20 times (does the “destroyed actor” print 20 times? Or you could have it print the final index to confirm). Perhaps the Z is slightly above the BP Box Replacer Reference’s, you could add a nearly equal check: http://api.unrealengine.com/INT/BlueprintAPI/Math/Float/NearlyEqual_float/

In the ForEach loop, what you are saying is:

  • If actor’s Z-location is LESS or EQUAL to Box Replacer’s Z value, destroy actor

But in the comment, you are saying that boxes below box replacer do not disappear?

The statement is always compare A to B, as in, upper node to lower node. The <= node can be read as A <= B. The whole statement would read more like

if ( A is less or equal to B ) { Destroy Object }

GetAllActors of class is a prototyping node for the most part. In a game, when you are spawning boxes, you could store them into an array and run the for each loop through that.