Parallax2D node help

Godot Version

4.6

Question

I am unable to get the Parallax2D node to work. I have a very simple scene setup attached below.

All I’ve done here is create a Parallax2D node and attach a Sprite2D node to it, assigning a sprite to it.

The game launches with the following screen:

I do not wish for this background to scroll and want it static. Thus i set both scroll scale to 0,0

Upon doing this, the entire background disappears.

I’ve tried a bunch of settings with sprite. Centered on/off - but no luck.

EDIT : The position is also set to 0,0 for the sprite and i’ve tried some combinations to get this to work - i.e centered on/off , position change and viewport related settings. The main issue is as soon as scroll scale is set to 0,0 - bg disappears (to start with)

How can I fix this? I’ve spent reading the docs and watching videos. Nothing seems to resolve it.

This appears to be a bug in the implementation to me.

Thanks!

Check the documentation:

It explains how to correctly setup it.

Yes, i have read them, but it does not address my issue. Is there something in the setup above you see that can fix it?

It does, it’s explained in the poor positioning section.

I don’t believe this is the reason. In the attached screenshot, you can see the position is set to 0,0.

I’ve tried a few combinations or tinkered with settings. These include viewport, centered, and position. As soon as the scroll scale is set to 0,0 the bg disappears.

Offset/centered position can show it well - offset , but this does not work either.

I’m not able to reproduce any issue with a similar setup as yours. Are you moving the Node2D root node? For example by instantiating it in another scene and moving it.

Not really - its a pretty bare-bones setup.

I’ve re-created it here in the sample project : GitHub - hgedia/godot-parallax-node2d

Please let me know if you see something off. Thank you!

From what it looks like, you probably are doing something funky with zoom (I’m guessing, since I can’t see your viewport box and it’s not the same size as your camera box)? In that case, the section you want is “poor sizing”.

Normally, you build your game around your viewport and target resolution and you zoom in and out as an effect. Setting the texture to 0,0 will do essentially the same thing as a CanvasLayer and stay in the top left of the viewport. What it looks like is that your background doesn’t fit your viewport, it only fits your zoomed in camera. If you don’t want to fix your resolution or zoom, then you’ll need to put your background in the center of your viewport, which is what will be displayed when you zoom in.

1 Like

Actually, just pulled down your project, and yep:

1 Like

Hello! I appreciate you taking the time to look at my issue and the repository. I understand partially how to resolve this. I grasp that using Zoom to enforce a resolution is a bad idea, but I can explain what I am trying to do. Sorry if we are going slightly off-topic into viewports/cameras.

One of the tutorials I am following recommended a way of choosing a resolution by using the zoom factor on the camera.

My display is 2560x1440 - So to enforce the width of 640x360, the camera applies a zoom (4,4) to it.

I certainly don’t have any qualms about changing the viewport or camera to the above resolution, but I guess I am trying to figure out how to set it up correctly so I can get the same view as you have attached.

I’ve tried the following.

  • Update the viewport size to 640 x 360 (Project→Display)
  • Set zoom back to 1,1 (Camera)
  • Tried to move the image into the camera, but it always launches with the below full-scale resolution.

Thanks!

EDIT : Solution is to set Stretch mode to viewport.

I recommend reading over this page of the docs here: Multiple resolutions — Godot Engine (stable) documentation in English

The main culprit is that you have the viewport stretch set to “Disabled” which means that it will never enforce a size. It’ll always match the size of your window. Setting it to any of the others will fix that.

1 Like