Looking for ideas of how to implement this

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.

Here’s a example: Klonoa - Longplay | Wii - YouTube

I was trying to figure out how to do that without success, do you have any idea of how to do that with babylon?

maybe a navmesh ?

The concept though is just about changing the forward vector of the player to point to another direction as required.

So all user input is always mapped to functions or physics that change the position of the character based on its forward vector , you are always only moving forwards and backwards.

1 Like

With the help of AI this is the result of the journey:

Path follow animation | Babylon.js Playground (babylonjs.com)

1 Like

It wasnt it what I mean :confused:

I thought to use it, but with that I’m completelly stucked on the path, like I’ll not able to jump or am I wrong? :thinking:

did you read what I wrote below the link ? I fully understand what you want , Ive even built it many years ago in unity engine :wink:

its about the forward vector of the character , you constrain to this and change only this etc… ( i personally just used triggers in unity to update the forward vector and relevant rotation )

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?

You should of course adjust your motion paths dynamically. e.g. if you want the user to jump, then calculate the points of the jump and start the new animation.

Could this be what you need ?

Press A or D to move the box along a spline path, you can implement other controls to jump etc.

As everything these days, blocks of code have been AI generated so it might not be the prettiest :slight_smile:

1 Like

what about physics? What about falling? or bumping into things? etc… Unless you rolling your own physics i dont think just using a path animation will work.

1 Like

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.

3 Likes

Sorry I actually didnt! It makes sense, I think this examples kind of makes it! https://playground.babylonjs.com/#K646HV#4

Now I’m not sure if it will work ;-;

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

1 Like

image
I have asked chatGPT to create a code for me.

This is the outcome:
jump and fly | Babylon.js Playground (babylonjs.com)

1 Like

I love the ‘path of truth’ expression :laughing: Makes me think of ‘MoT’. There’s kind of a marketing feeling behind it (may be to better ‘sell’ your solution for it :grin:)

1 Like

No worry, I’ll see what I can get this weekend, but thank you!