Hey again, you probably could use the trace option still: Once you have returned all actors that are hit by the trace, get their location and only store the ones that have a distance of let’s say around 100 units apart (if the box size is 100 units) from the previous one.
tracedBoxes = linetrace #linetrace gives you a list of actors that are stored in this ‘tracedBoxes’ array
moveTheseBoxes.clear #clear new list of actors that should get moved
previousActorPosX = pawn.posX
for each in tracedBoxes:
Xpos = each.getLocation.posX
if previousActorPosX - Xpos == 100:
moveTheseBoxes = append moveBoxList.getLast(each)
previousActorPosX = Xpos
I’m just shooting from the hip here in some pseudo code but I like to think that’ll get you somewhere. All it’s doing is going through the list of actors and stores them in ‘moveTheseBoxes’ until it finds that the distance between the prev and next actor isn’t 100. It assumes a linetrace will give you a list of actors in the order they were hit from the ray, as long as the ray is shot from the pawn. I think that’s a safe assumption but you might want to check that.
Don’t count on getting an exact number of 100 even if the boxes are spaced out at 100 units from each other, you’ll have to put in some logic to deal with numbers like 100.000001 etc but that’s pretty easy with the math nodes.
If there’s something I’m missing storing all your boxes in a 2d array might not be so bad. You can easily iterate through that as well. It’s likely less code with tracing though.