Moving wall / cube pushes player in steps and not smoothly, how to fix? [SOLVED]

The other day a thread offered a question about how to make a Gradius / Life-force style game where the camera sort of drags the player a long at a set rate. Creating a shooting game like Gradius V (newbie): side-scrolling game

I offered him a solution that works but I could not figure out how to make the player get smoothly pushed forward by the back bounding box.

Here is a video of the effect. Vimeo

I notice how that I guess the capsule component gets so far in the cube and then it just like instantly snaps the player ahead. I want that to be very smooth matching the speed of the pan. When the capsule component touches the box it scoots the player forward.

Can this be done?

Thanks

shoving the player along using physics wouldn’t be a very nice way of doing a game like that, a better way would be to just set the player’s actor itself in motion, but if you really want to use a pusher wall i’m sure you could smooth it out somehow

1 Like

I must sound like a borken record of late.

IS sub step on?

And to sound a bit different.
Are you replicating movement? Because that’s typical of replicated updates. And something you have to do differently if dealing with replication.

There is no physics, it is a camera actor separate from the player moving at fixed Y+ rate when play is pressed.

“but if you really want to use a pusher wall i’m sure you could smooth it out somehow” I’m open for suggestions for this type of game. Some mechanism to keep player on screen. I used a cube but there is probably other solutions.

No, but I turned it on and tryed and no effect.

Not replicated.

Hmm…watching it closely with the capsule component visible, when the capsule is perfectly halfway in the wall the jump happens. Need for that capsule to move the moment it overlaps that wall.

if your camera is attached to the player’s actor it will remain following him so he is automatically always on the screen, but we should probably keep them separate. also, instead of forcing the player forward at a fixed rate, you should probably be forcing the camera forward at a fixed rate, because that will let the player move freely around the screen as it’s moving. but he must be prevented from exiting this screen area to contain him inside the box that the camera can see, and you could easily do it by checking his position variables relative to the camera. when done this way you don’t even need to use a moving wall at all because if he falls offscreen he simply dies by calling destroy function on the player.

Nothing magical needed. No sub stepping, ccd, physics etc. The issue is with the shape of the characters capsule component. The fix is to add a small box collision to the base of the wall. This is what will interact with the capsule when the player isn’t moving. The wall mesh will handle pushing when there’s jumping involved.

Demo with BP overview.

Box Extent Dims [X: 8.0, Z: 5.0] … Seems to be the smallest I can go with my character setup.

2 Likes

I don’t have any issue with the default capsule component.
it just moves along with the wall as you’d expect.

makes me think the wall collision is off or something.

Yes, that is exactly what is happening in the first vid. Having a separate camera actor moving at its own pace should be helpful down the road, like encountering a mini boss at the end of a level and the camera stops and the player is forced to stay in one screen sized box with mini boss.

The OP’s original question and goal was to make a Gradius style game, in that case the ship or craft is pulled along if the player goes all the way to the left of the screen (for old CRT TV there was probably a safe zone there). I doubt that Konami was using the exact same mechanism as a wall for that effect (perhaps a boundary of some kind though), but in UE4 I imagine it would have to be done. But like you, at this point I’m starting to think there might be another way to achieve this.

This pic below, I think would work. As the player’s capsule overlaps the wall, the capsule receives an offset positive in the Y matching the wall’s speed. This code is in the third person character BP, so I just need to get a reference to the moving wall to plug into is overlapping boolean.

Many thanks for making this RevOverDrive!

That code is very helpful, I was using the level BP for the camera actor movement. With this code I was able to place that code directly in the camera actor BP.

I see what you did there, it kind of makes a small edge or lip on the bottom of the wall, to reach the bottom of the player’s capsule before the wall does, kind of like the tines on a bulldozer bucket touching a wall before the bucket does.

I tried this and it does work!

https://vimeo.com/manage/videos/647497346

The problem then becomes when player jumps on a higher or lower platform and the edge is not there and the old problem resurfaces :frowning:

I see a few more issues in the vid I just posted, with player essentially sticking to the wall.

I would think then based on this approach the solution would be to do the opposite, attach a small cube (or body sized cube) to the player that would either push the capsule or be a boundary itself. Both cases would require that this “cube” would be a parent over the capsule component, and I could not get that to happen. Some error about the capsule is inherited and has to be the root for the character. Then perhaps a cube could be attached at runtime in the BP, but then how could you make it parent over the CC?

If I add this piece of code to the third person character.

I get this effect…

https://vimeo.com/manage/videos/647576290

For this type of game, that is actually a very needed effect I would think, the player character is constantly pushed positive in the Y direction at the same rate of the wall. Giving the effect of movement. I suppose all one would have to do is swap out the player mesh with a rocket ship, and change around the controls a bit and the basic controls of this kind of game is almost down.

But then I don’t understand why I can’t turn that effect on whenever the player’s capsule overlaps that moving cube (wall). I tryed to do that and whatever I tried I could not seem to get it. But I think that would solve this problem.

Any ideas?

You could just add a constant value to the character movement in the direction of your world. Just use a select node: if no key is pressed (scale value = 0), move character in X direction with X value.
Screen Shot 2021-11-19 at 11.44.37 AM

This will make the character walk slowly in that given direction rather than slide along.

1 Like

Thanks for your reply, the code that I last posted that you quoted seems to do the same effect that you are mentionin or refering to, your solution seems to provide yet another option for such as effect.

That is not the current problem, the current problem is how to gate that moving effect so it only activates while the player’s capsule is overlapping or touching that back wall, everything I tried did not seem to accomplish that. Perhaps I should try turning off all collision for that moving cube and just using it as something to overlap.

That didn’t work either, and wouldn’t because if the player’s capsule is not blocked by the wall then the player could go through while holding toward the direction of the moving wall.

And all this effort because of the shape of the player’s capsule component. There is probably a way to take RevOverDrive’s idea of the small edge and make it move up and down according to the player’s location, but I think there must be a way to add just a body sized cube to the player to act as a boundary.

If this is to my suggestion: You need the wall. I should’ve quoted the video, not the image… my bad. My suggestion was only intended to have the character walk with it and not simply slide, assuming you will want the wall to be invisible eventually.

i tried this yesterday and i got it to push the player without any wall, it took a long time to set it up. the wall method would be way easier.

It seems like a mad amount of effort to do something so seemingly simple. And it is all because of the capsule component’s shape why this method is so difficult. I would like to place something above the capsule component so then the CC would be parented to it and thus be moved by it.

But apparently that can’t be done, another thread about a square capsule component said “This cannot be done because the capsule component is inherited from its base c++ class” that would be the character BP.

you can make a pawn instead and give it a cube shaped component. the character is just a pawn which has got a capsule component on it. old games used cubes like this instead of capsules so it should work fine.

Honest question: is the capsule shape really an issue?