There is a type of game I call a “Shipscroller”, these games seemed to be a very popular type of game 30+ years ago.
Essentially the player character is a ship, jet, or craft, etc. That has general movement abilities for up, down, left, and right (plus diagonals). That is moving along at a set speed. The effect of parallax scrolling seemed to help create the feeling of “speed”.
Generally these type of games seem to come in two primary variants, side, and top, with all others being a variant of top or side or even 3d or 2.5 D variants.
In the side form they generally move from LEFT to RIGHT so Y+ (depending on how you set your map up surely), however there might be times when the direction changes to RIGHT to LEFT, case in point off the top of my head would be U.N. Squadron by Capcom, where the player was attacking something big like an aircraft carrier, and if all the destructible points were not takin out in the first pass, you would hear a swoosh sound, and the speed would slow to a halt and you would see an animation of the player’s jet turning, and then the shipscroller LtoR movement changed to RtoL movement.
But then how does one achieve such a thing using Unreal Engine? In Blueprints?
Based on what I have learned with my Beat Em Up template through the years, I went back to the concept of the parallel moving camera actor, this camera is moving and will thus force you to move as well. I have experimented with many such things such as attaching box collisions to this moving camera actor to block the player. And while this did seem to work fine with a Beat Em Up (Sidescrollers too), I could not get it to work with a Shipscroller type game. I asked for help about that here. Perhaps the easiest explanation was that I was trying to use a made from scratch pawn bp VS a TPC or duplicated character bp that contained a capsule component and thus for some reason just could not seem to work.
It was @ClockworkOcean and @Suthriel that suggested to me try to limit the players movement to achieve the same kind of boundaries that I would normally have tried to use box collisions for in this type of game.
I honestly would have prefered to just use 4 box collisions for left right up and down to block the player, I also just want to see it work though…
The first thing I made was a bp - actor, and named it CameraActor. Inside I added a camera, saved and closed it.
The level - One of the hall marks of these types of games is what is known as parallax scrolling. Essentially, when you are in a car going down the road and you look out the window, you see the things closer to you moving faster than the things further away from you like the mountains. Shipscroller games back in the day seemed to achieve this look by using several parallel layers of images that moved at different speeds to achieve the look of motion similar to reality.
To achieve this look, I created 3 primary layers in my landscape. And these were arranged in primarily straight and long parallel strips. Giving me at least several minutes of flight time.
The first layer was just close mounds, the second layer was slightly larger and spaced out mounds which is distanced further from the first layer, and then some mountains even higher and spaced out from the second layer. You can add more layers if you want, I think I may have made a 4th layer event further out with a prop based mountain top.
The idea here is to have the camera actor move to the right or Y plus and parallel to the player and looking at this landscape and achieve essentially the same thing as the Shipscroller games did.
Inside your camera actor, you will need to set the “speed” it moves. Again thanks to @ClockworkOcean for suggesting this more controlled movement VS what I had normally, as this would allow me to actually slow down and speed up movement when needed.
Keep in mind here that whatever your CameraActor speed is, your player character will have to also have the same exact speed for it to look right.
Open your character blueprint. I ended up using another character bp for this, and first thing I did was selected the capsule component and turned off gravity.
Go back to the event graph. The first thing here is to set the Shipscroller speed, and again, this has to match the CameraActor speed. You also need to create a variable - float and call it current height. Lets go head and set that variable along with our overall speed. Drag out the static mesh - GetWorldLocation - right click the output and SplitStructPin - and drag out from the Z to set that variable. That set should go between an Event Tick and a SetActorLocation. Get a GetActorLocation -split struct pin - Feed the X and Z to the set actor location, drag out from the Y and add (float), this number here is important for your speed. drag out from the output of the add and get an FInterp to node.
The target input should be the output of the add node. The Current output should be the Y output from the GetActorLocation node. Drag from the Delta Seconds of the Event Tick to the Delta Time on the FInterp To node. The Interp Speed at the bottom of the FInterp To node is also important for your speed. And these should match the camera actor exactly.
Now you can test it. Also try to make sure you are using a Player Start in your map VS a dragged in bp here, I was having a trouble of a ghost or phantom player character also spawning until I did that.
If all goes well you should see a Shipscroller moving along at the speed you picked. BUT, there is more to it. You need to be able to move Up, Down, Left, and Right (plus diagonals), but you only need to be able to move so high, so low, so far right, or left.
As anything else in Unreal, there is surely many ways to do this. What I did was go out of that first SetActorLocation as my main fire or driver for all this, as that is a fast firing Event Tick fire.
I first checked if my diagonals are being pushed by inputs.
This is feeding four branches, and here I added three custom events for like “TRUE - Press Up and Right” etc etc and placed them accordingly. I also added a custom event for “FALSE” at the end of those branches.
While messing with this, it seemed not too difficult to get the max and min height of my character. But how was I going to get the max right and max left? Here I opened my CameraActor bp and added two planes, rotated, scaled and positioned them accordingly left and right and called the left one 'CA Max Left" and the right one “CA Max Right”. I will use these traveling planes attached to the CameraActor to help me calculate the desired max left and right for the character. Compile / Save…
To access this, we will need to get a reference to our CameraActor from within our character bp. And again, there are surely many ways to do this, I will find an empty space in the event graph out of the way and add an Event Begin play, and use a GetActorOfClass node and set it to CameraActor, right click on the return value and choose promote to variable, named it “Camera Actor REF”.
Also, I forgot to mention, I also added a set movement mode to “Is Flying” here for the character after the begin play and before the CA REF (IMPORTANT).
Make 4 more variables - float - “Max Height”, “Min Height”, Max Right", “Max Left”.
To find the numbers you need for Max Height and Min Height, you can simply go back to where you set the Shipscroller speed and came off the Z from the GetWorldLocation of the StaticMesh and feed that to a PrintString, change Z wire to the In String instead of the Duration and plug it up. When testing don’t forget to press F11 to full screen for max and min height estimation.
To find the numbers for max left and max right is a little more difficult but not too bad. It will mean getting a ref to your Camera Actor REF, and from that getting the CA max left or right planes, then plugging that in where you need it.
Now back to those TRUE outputs on those first four branches that check our diagonals. Those custom events will send the signals here. Find an open space of the Event Graph for all this. Draw out a lasso on these sections and press C and comment it to keep it organized.
For the sake of time I’m just going to show you these nodes. Essentially you are checking if things are less than / greater than and addingactorworldoffset accordingly.
Now to check for just Up, down, left, and right inputs.
Remember that 'FALSE" custom event? That starts the signal here. Here you will be setting up, down, left, and right offsets, and again comparing if numbers are greater / lesser. the speed up, down, and left, here I chose 75 but you will have to set what you want / need here.
If everything goes well, you should now have a decent looking Shipscroller movement.