Pawn Moving Objects Together

Hi All…

I’m needing some help/advice.
i have a cube(Actor Blueprint) that can be kicked by the pawn 100untis in whatever direction the pawn is facing… works great.

But my question is…
How would i approach… if there are multiple cubes bunch up in a line, That when i kick the first one, they all move together.


A few questions need to be answered - I take it this is all custom stuff, ie no physics? I assume so since you said 100 units, it seems too exact to be physics driven. :slight_smile:

How do you then trigger the pawn kicking the box? Overlap?

Without knowing exactly what you do, I’d maybe suggest calling ‘OnOverlap’ on the box, inside the box blueprint then somehow find the direction and velocity (mind you not velocity in UE terms as that implies physics, which I don’t think you use and therefore won’t work) and trigger the move that way.

You could also store the boxes in arrays if this is a 2d type puzzle game and get all array items left of current pawn when pawn hits first occupied array. That could be overkill maybe… every time I think a 2d array would help a problem someone else comes and solves it elegantly without one. :slight_smile:

Maybe you could use a multi line trace in the pawn’s direction upon kicking to return all boxes and move them all as well.

It’s a bit hard to suggest things as I’m not sure exactly what you use, and I’m also not an Unreal genius. :stuck_out_tongue:

Hi… thank you for helping…

Yes i should have explained more…
I already have the box blueprint tracing on each side of the box and then when trace returns the correct hit. i know what side of the box the pawn is facing and therefore the box moves in correct direction when kicked/pushed. I also don’t use any physics, velocity etc, didn’t have the control i needed, because everything needs to be on a grid… ie. moving it exactly 100units with each kick/push… so i use lerps with timelines to achieve this.

But my question is… when i have multiple boxes in a row on the grid…
If kicked or pushed the first one. the others would should move too…
So im trying to figure out the best way


So if you use a multi line trace instead of a single one you should be able to get all boxes. The multi line trace outputs an array so do a for loop through those and you can get every box, and move all of them accordingly.

That should work, you might have to setup custom trace channels/limit the trace distance/ignore certain objects etc to return only the type you’d want to move (in this case the boxes).

Hope that helps!

Hi Thanks for the reply.
But i have already tried this, and its not want i need,
I cant have a preset distance for tracing out to see if there is more than one box, because they could be any number … and plus then muiti line trace does not take into consideration if gaps are between the boxes. therefore all boxes shouldn’t move. etc.

Some how i need the box itself to know if it has other boxes next to it in the path it needs to move and then move the other boxes with it.
Can anyone shed some light for me… on how to approach this

Something along these lines im trying to do.

Anyone know???

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.

Hi… RumbleMonk… Thanks for the info…

I was wondering if you could help me out with some direction.

I’m able to kick cubes around a grid…
ie 1 grid per kick(100units)… and can kick them when there are multiple cubes lined up and i know what group of cubes to kick if there is a gap between cubes etc…

But now im trying to do a long kick…
Which is to kick them the length of the grid board… if its a single cube or even a group of 2-3-4 cubes, that’s no probs.
My Issue is. if i have 2cubes grouped and then a grid gap and then another 2 cubes grouped… how can i get the first grouped cubes to push the other grouped cubes further down the line

So basically im needing something like this… But physics don’t seem to controllable enough… so i need to code it.


Shouldn’t be too tough now that you have your kick already working.

Just kick it along 100000 units instead of the 100. When it hits another actor of the same type initiate the same 100000 unit movement and then have them stop when they hit the unmovable object. You will just need to do a trace check to see if the 2nd and 3rd should stop too. Id probably just do a trace from them and increment the length of it by 100 units for each block that gets added on