I’m trying to figure out the best way to do a auto side scroller. Every tutorial I’ve seen shows character-driven camera movement, but what is the best way to have the environment/camera drive the movement?
Two examples of this are UN Squadron (an AMAZING SNES SHMUP) and the aero levels of Cuphead.
I thought about “forcing” the player forward with a constant velocity that can be added and subtracted from (not sure that would work). I would use two collision planes just outside of the camera to keep the player within bounds.
My second though was to move the entire landscape and its actors through the player, but that seems CRAZY inefficient and stress-inducing. (I actually think this is what they did in these two games, but they used flat planes with parallax motion.)
Also, to further clarify my dilemma, if there are enemies on the ground that could move (i.e. tanks and missile launchers) independently of the scroll, I’d have to ensure that they are moving ALONG with the landscape (and not that the landscape would slide underneath them), and that seems like a logistical annoyance, which is why I’m hoping there’s another way.
So yeah, character-based is the way to go- but keep in mind exactly what’s going on.
The camera can still be a sidescroll-at-specific-speed thing. You could do something like put the character’s scene node on a spline, and the ship moves within an x/y range of the scene node freely in local space while moving in worldspace with the node.
I know it works because I did it to build a starfox clone- you just have to wiggle some things around to make it a side view game. But building the level is where most of the issue is there- that’s a lot of ground to cover!
The character’s root would be a scene node center screen. That node will travel on a spline and take the camera, skeletal mesh (or don’t if it’s say mario but that’s another conversation) and ANYTHING the player owns along with the scene node. That scene node moves the way you make the spline- so you could even turn corners and stuff if you really wanted to, or turn and go straight up. The level stays still, the spline is a rail and the scene node (root) of the character is on said rail.
You’ll lower everything else to be below the scene node. Parent the camera directly to the scene node, and do that with the pawn as well- don’t parent the camera to the pawn.
All of your inputs, have them affect the highest point in your pawn (probably your collision) and it will move the rest of it. CLAMP that movement to whatever distance you want in X, Y(probably 0), and Z, and boom! (get this done before the spline part).
As far as movement along a spline, there are multitudes of videos for that, but to type it out would be a long process considering I know you know quite a bit of the steps involved already.
You may want to go ahead and make the character- block it out! Just use a cube for your ship, and put a little sphere in the hierarchy as a sibling to the camera and the pawn at 0,0,0 so it stays centered and you can visually confirm the movement.
Levels come last! Always. You need to have your mechanics down first: ship speed, shooting, and basic enemies. Because then that will determine HOW you build your levels, as you build your levels around the capabilities of your player!
For instance- how would you build Super Mario Bros without knowing the player’s peak jump height/distance- when sprinting vs normal movement, where to place a fire flower and then a good wave of enemies to blast with it as a reward for not being hit, etc.