Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallax2D fails to repeat correctly, and scrolls at incorrect speed. #92031

Closed
MetalPetalArt opened this issue May 16, 2024 · 3 comments
Closed

Comments

@MetalPetalArt
Copy link

MetalPetalArt commented May 16, 2024

Tested versions

4.3 Dev 6

2024-05-16.16-46-32.mp4

System information

Linux Mint 21.3

Issue description

Never thought I'd actually go through all the effort to make a Github account, but Godot spurns me. I have been attempting to set up and mess around with the new Parallax2D node. However, as you can see from the awful sprites in my example video, the scrolling and repeating functions of Parallax2D don't seem to be working as intended. I parented the nodes to a Camera2D, which is the same way I set up the old Parallax nodes in previous versions of Godot.

The specific issues that I notice is that when setting a scroll speed for the node that is below 1, they begin to scroll in the opposite direction of camera movement. When setting this number to a value above 1, the scrolling instead moves slower, as it should when the number is set below 1. The second issue is that after the node has scrolled far enough, the background stops repeating. Changing the number of repeat times will allow the background to scroll further before it stops repeating, but it doesn't cause the background to repeat as it should.

Since the setup is the same but the issues are new, I assume this is a bug with the nodes but I could be wrong since there isn't a whole lot of info on the new stuff currently.

Steps to reproduce

Set up Camera2D to follow moving node, or move the camera itself
Parent 1 or more Parallax2D nodes to Camera2D
Set Repeat Times and Scroll Scale values to a non-default value

Minimal reproduction project (MRP)

parallax2d_bug_mrp.zip

@markdibarry
Copy link
Contributor

I notice in your video and in the MRP that you have the Parallax2D node as a child of your Camera2D. Although I've never seen anyone have their backgrounds as children of their camera before, after thinking about it a bit it makes sense how it's behaving, so this is expected behavior. This isn't a recommended setup, and if you move your Parallax2D out of the Camera2D it should work correctly.

A few more tips for working with Parallax2D and its predecessor ParallaxBackground:

  1. When arranging your scene, make sure your background's top left corner is at 0,0.
  2. Your background should be the same size or larger than your viewport.
  3. Set the repeat size to the same size as your background.
  4. For a more consistent start when running the scene, make sure your camera's top left corner is also at 0,0.
  5. The repeat times only need increasing when you need your camera to zoom out.

Attached is your MRP with some of the above fixes and I added a few more layers at different speeds so you can see it working. Thanks again for making a Github account, and please report any other issues you see!

2024-05-16.19-48-55.mp4

parallax2d_fixed.zip

@MetalPetalArt
Copy link
Author

I notice in your video and in the MRP that you have the Parallax2D node as a child of your Camera2D. Although I've never seen anyone have their backgrounds as children of their camera before, after thinking about it a bit it makes sense how it's behaving, so this is expected behavior. This isn't a recommended setup, and if you move your Parallax2D out of the Camera2D it should work correctly.

A few more tips for working with Parallax2D and its predecessor ParallaxBackground:

1. When arranging your scene, make sure your background's top left corner is at 0,0.

2. Your background should be the same size or larger than your viewport.

3. Set the repeat size to the same size as your background.

4. For a more consistent start when running the scene, make sure your camera's top left corner is also at 0,0.

5. The repeat times only need increasing when you need your camera to zoom out.

Attached is your MRP with some of the above fixes and I added a few more layers at different speeds so you can see it working. Thanks again for making a Github account, and please report any other issues you see!
2024-05-16.19-48-55.mp4

parallax2d_fixed.zip

Well that's good to know, and moving the Parallax nodes away from the camera seems to have fixed these issues. Though now I'm really wondering why this set up worked with the old ParallaxBackground node. Regardless, thank you for the response.

@akien-mga
Copy link
Member

Thanks for the report, and thanks Mark for the detailed explanation.

Closing as this doesn't appear to be a bug in the end. If we find that more users run into similar issues, we could consider adding a configuration warning when Parallax2D is a descendant of a Camera2D node. But I agree that a priori this doesn't seem to be a commonly used scenario.

@akien-mga akien-mga closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants