Hey all, I’m working on a 2.5d sidescroller game, but what I wanted to do is a little different from what we’re used to see as a 2.5d game.
I want to make something similar to what Klonoa does, its mostly a sidescrolling game, but it is actually 3d, the player can move only on the right/left and it its kinda attached to a “rail” on ir, but the path isnt linear, it has turns, clives and actually change the orientation many times.
If it should be “like a railroad”
I think what you want is just an array of vector3’s to lerp your characters position along the x and z axis, while still allowing adjustments on the y axis for jumps and falls?
What you need to do is make a path that you use as the “path of truth” for the Character. When the character moves, you need to first establish the closest segment of that path to the player, and from that you can get your direction that you need to offset the player, if the “direction” changes then you lerp the players rotation toward that new direction while always moving the player along that “normal” of the closest path segment.
After you do that, you need to have a secondary spline ideally with the same number of segments as the player path, but offset where you would like the camera to follow the player. After you have offset and established what segment you are nearest, you want to get the closest point on that segment to the players positions. Once you have that point, you need to figure out where that point lies on the entire paths length. Once you have that normalized distance position of the closest point on that path, you will apply that same distance to your camera path and figure out what the position is for the camera from that, simply lerp to that position and slerp your target to the new player position.
This way there can be multiple platforms on the same segment and you could support pretty much any shape of path along with physics or a custom movement system.
Another method that might work would be to use, “zones” and trigger a new camera normal offset whenever the player moves into the zone. Then you would simply have a normal and a distance for each trigger. Once the player hits that zone, you update the cameras positions as like player.position.clone().add(offsetNormal.clone().scale(offsetDistance))
and just Slerp the cameras target to the player position.
The best method might be a combination of the two so you have your player path, and then offsets zones you could apply to the camera path. Then you could really control the camera flow and positions. For example you could have a section that even though its on the same segment you need the camera to zoom out so the player can see another platform. To do that as a path it would be tedious AF. But if you had the path that it was following that was simple, then it passed into a trigger volume, you could modulate all that pretty easy.
I am soooo overloaded with work, otherwise Id make you an example. Focus on the whole sampling the closest point on a segment first. Once you figure that out its just remapping that sample to a new coordinate space and applying that to your camera. <3