Camera2D Issues

Godot Version

4.2.2

Question

I am currently working on a project that’s kind of like salt and sanctuary or a game like that if you know what that is. The way I have it set up is that there is a class selection screen and then once the user clicks play the “World” scene is loaded and based on the button the user clicked, a Packed Scene of the character is initialized into the scene.

This has worked so far with minimal errors. I got some animations going and a platform working. My issue comes with the camera. I am using a parallax background with 3 parallax layers. I have attached the camera to each character scene (I have 4 separate scenes, each being a character2d scene) but when I load in, I can see the platform I am standing on but not the background

I have also tried setting the camera on the world scene and dynamically attaching it to the character when it is loaded in but I couldn’t get that to work.

Any information on how to get this to work is greatly appreciated and also if what I am doing with the characters is completely wrong or a horrible way to do it please let me know. This is just the way my mind worked through the problem

Have you tried using the RemoteTransform2D node to make the camera follow the player? And I also wanted to chime in and say that I am doing the same technique for choosing player classes :smiley:

I just gave the RemoteTransform2D a shot and I am getting the same results unfortunately. I figured it was better to attach screenshots of my setup so maybe people can figure out what’s going on


This is the problem I am seeing. I see the platform I am on but I do not see the background

Like I said I initialize the character into the scene on load so I’m not sure if that has something to do with it.

in Godot 4.2 I prefer use shader for parallax effect

shader_type canvas_item;

uniform vec2 position = vec2(0.0,0.0);
uniform vec2 speed = vec2(1,1);

void fragment() {

		COLOR = texture(TEXTURE, UV + position * speed);
}

you control shader with scripts. and Texture needed have repeat mode.
Godot 4.3 have new Parallax system easier to use

Can you send a picture of the remote view of your scene tree while the game is running?

I figured out the problem. After going into the remote view I realized the camera is offsetting the background by my characters position (the cameras position). I’m not entirely sure how to fix this
image
This is my remote tree
image
You can see the position being moved with my character. The x also gets affected I just haven’t moved in the example

You don’t need to place a ParallaxBackground node in a CanvasLayer, because a ParallaxBackground is a CanvasLayer, so it will never interact with anything else on other layers except the closest camera. 4.3’s Parallax2D is similar but isn’t a CanvasLayer.

The best advice for parallax effects is to get it working by simplifying, then add complexity. For example, make sure that you’re not accidentally zoomed in with your camera, or your parallax nodes or sprites are scaled. You can find more information on common pitfalls here in the tutorial. It’s for Parallax2D but most of it is relevant for the old parallax nodes too.

I fixed the problem, I don’t know exactly what it was but I deleted the parallax background and all the nodes and replaced them from ground up and it worked. I have a feeling with all my tweaking and messing around I hit a setting somewhere that made it all jumbled. I appreciate all the help guys :slight_smile:

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