Player moving between parallax layers

Godot Version

4.2.1

Question

Hello, can someone guide me on how to make the player move from one parallax layer to another in Godot 2d during gameplay? A 2d parallax simulates a 3d environment but you can only move along x and y. I want to make it possible to move the player from one parallax layer to another making it like he’s moving along the z axis (e.g. there are two ground layers but on different parallax planes and moving at different speeds from one another but at some precise moment there is a chance to take the player between the layers taking the player up and down on the game screen). The only example I can think of now is Old Man’s Journey where the main mechanic in the game is the player seamlessly jumping/walking between layers.

What would be the best strategy to approach this?

I think because of the way parallax layers are implemented in godot this is not easy. What would be much easier is to just use regular canvas layers scripted to move at different speeds and then switching the reference layer. More involved, but easier to control and reason about.

2 Likes

I may be misunderstanding what you’re asking, but it sounds like you’re looking for a 3D effect. At least, the game you mention (Old Man’s Journey) was made in 3D, to give a 2.5D look. The benefit you get from this, is that in order to move your character to another layer, you just move them closer or further to the camera. To attempt to replicate this effect in 2D, you’d need to create quite a complicated system of collision and rendering layers, and when you move a character further or closer, you’d need to scale the sprite and collision (not recommended), and adjust all moving objects speed to accommodate the fake distance.

1 Like

Thanks for the answers. To clarify a bit more, I’m not looking for a 3d effect (apart from the existing parallaxing) and there would be no scaling action involved just the player changing its location on the screen and its position inside the level tree. What I’m saying is I want the player to teleport from one layer to the next one whenever the player is moved to a specific location (e.g. Area2d). Pretty much the same as going from one scene to the next one just between layers.

Ok, I was confused because the example you provided was a 3D project. If you want to achieve it in 2D, I can at least think of a few things you’ll have to consider.

  1. ParallaxBackground works based on the camera’s position, so it’ll have to be very intentional and on-the-rails when you move it.
  2. If the character will not be scaled when reparented, I’m not sure if it’ll look like it’s further/closer, which is kinda the point of the parallax effect.
  3. If you want to instead move the other layers closer/further, while keeping your sprite the same size, you’ll need to craft a custom setup. Ideally, one where every time you move your character from from one parallax layer to the other, you’d disable everything in the previous scene, and update all layers scroll speeds to spread out based on your current layer.

The important part is that even though it’s giving a faux-3D effect, it’s not, so if you have any collision on more than one layer, you’re going to have a huge mess.

Any mockups or examples would allow us to give more advice!

1 Like

Thanks for the suggestions. However, I found a very simple solution (will do for now): I drew several NavigationRegion2d areas in separate parallax layers (starting from my initial layer in the front) attached a NavigationAgent2d node to the player, and put together a pathfinding script for the player to move inside those areas (basically a point-and-click system). I made it so that when the player wants to go up the level and move from one parallax layer to the next one the NavigationRegion2d areas in the parallax layers align perfectly in the specific spot (a road going upwards in my case) for the player to change planes seamlessly. The parallax in this case kinda works like floating islands where you would jump on a moving platform and it takes you away. Now, to not have the player always on top of the sprites I just changed his ordering position (z index) inside the script whenever the player enters a specific NavigationRegion2d area.

I’ll put an example here later. Until then I mark this as solved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.