Trying to push a box with a character

Hi guys ,
I have modeled a simple character , made walk, jump and idle animations and now i want to push a box through the level with it.
When i check physics the box moves, but i just want it to stay flat on the ground and move.
I added a simple box , checked generate overlap events, checked that in my mesh too , and i printed string to to the screen to check if the overlap event is firing,but
since i am new to the engine i don’t get it , how to make the box moving?

I think the logic should sound like this:
When the overlap event is generated , change the animation of the character to the pushing animation and translate the box to some of the axis.
But how to tell that to the engine?

Turn on physics for box, make sure box mesh has collision, make sure that its mass is somewhere in pushable area.

Do not use default box that is scaled down, scaling meshes sometimes gives weird results with physics, probably will work most of the time but then you get that weird behavior that is very hard to find what caused it.

When you play with physics, at least have this open in browser for reference: Physics | Unreal Engine Documentation

Ok , so i did that:
but the result is not what i wanted. I want the box to stay flat on the ground and moves the direction that the character is “pushing” it.
I am getting the location of the character, and using it to move the box , when the overlap event is fired, but that doesn’t do the trick. And in make vector i set the Z position to 130 so i am sure that the box always stands on the ground.
The problem is that the box is “jumping” I don’t push it smoothly, and sometimes the box jumps on the other side of the character, i am guessing this is because i am using the character location.
Oh, and what collision preset should i use , so that the box collides with my character and with the walls(don’t go through the walls)?
Thanks for any help.

I did project that pushes trees, so they fall. You may adapt it to your project.

Vinterpto needs to be done on event tick (google for interpto tutorial).

For something like that since you want it in a straight line in 4 directions you don’t really want to be using physics. What you are doing with your blueprint is pretty close. You can do a tick but personally I would avoid that, I would create a timeline with a start value 0 and end value 1, use the alpha value to lerp between its current position and position +130

OK , i figured that out, i made it like this:
but as always !! :(, this led to another problem. The box that i am pushing is not staying in the level(not colliding with the walls.) The walls collision is set to block all, the box is set to “Movable”, collision settings are set to BlockAll, except pawn.
i tried to change the object type to: WorldStatic, WorldDynamic or Pawn, but the result is the same.

Thats because when you are moving it its just setting it’s location, it no longer cares about collision.
What you will want to do is trace from the front of it and check there is nothing there. If it has enough space to move than allow the movement, if not than don’t allow it to happen.You will probably want to play a different animation of the dude struggling to push it or something to signal to the user.

Ok , this is what i made:
I added a trace, and i am using it’s return value in a Branch, as a boolean after begin overlapEvent to determine if the timeline should be played or not(if it is false, go on, move the box from one position to another).

After the trace I set the “hit” boolean to true, so if the box collide with something dont move it anymore, but since maybe i cant move it forward but maybe i can push the box from the left side then i added another branch, where if the condition is true, delay 3 seconds and set the variable “hit” to false so I am able to move the box again. So, basically after 3 seconds i can move the box again.

I am sure that is not the best way, but i couldn’t figure out another way to be able to move the box again in a different direction. I don’t know hot to check how much space i have left behind the box, so let’s say if the space behind the box is more than 300 units , ok , move the box.
I’ll make another animation ,where the character is pushing the box in 3ds Max, and add it when the overlap event is triggered, but want to clear the logic first. :frowning:

I would be doing it independently for each side of it. You should just fire off an event when you attempt to push, in that event you should check the direction you are trying to push it to and if the direction is valid because it doesn’t run into anything then allow it to push.

Lol, thanks! That was actually pretty simple , of course ,another problem came out , i was going through the box if i am not allowed to push it. But i added a blocking volume, made it the same size as the box , and if there is a collision i am just changing it’s location to the location of the box , so i stop in front of the box if not i am just sending it up in the air. I don’t know it this is the best way do to it.
Really, THANKS for the help, don’t think i would be able to think of that on myself.

No problem, glad you managed to get it running.

For the actual player movement I would do it with animations and you don’t allow the movement unless the push is possible, that way you can give him a struggle animation without pushing it. The old Zelda games are my mental reference for this type of block pushing

I want to make something like “Sokoban” do u know it ? Old logic game , where you must push boxers to their places. I am sure different problems will lie ahead, but will do it. :smiley: