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

Prevent Parallax2D autoscroll reset #96245

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

markdibarry
Copy link
Contributor

Pointed out by @Mickeon, autoscroll currently resets the offset to 0,0 every time it's set. This is undesirable, because users may want to update this value on the fly to speed up or slowdown the scroll. The current behavior may be needed in some cases, so rather than exposing the autoscroll_offset to be able to update it manually, we remove it, and use scroll_offset internally instead.

Also, apparently Math::fposmod(0,0) returns NaN, it just wasn't a problem until now, so a check was added in those cases.

Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a good chunk of "offsets" to think about with Parallax2D, and this PR removes one of them, which was previously only available internally.
Seeing the scroll_offset changing in the Remote Tree instead of some arbitrary internal value is considerably more intuitive. It helps implementing custom scrolling behavior, as well.

This breaks compatibility but that's exactly why Parallax2D is experimental.

@akien-mga
Copy link
Member

This breaks compatibility but that's exactly why Parallax2D is experimental.

I don't think this breaks compatibility, at least in the usual sense of breaking the API (adding/change/removing methods/arguments from the public API). Changing behavior of an API is the natural consequence of any bugfix so it's not considered a compat breakage.

@akien-mga akien-mga merged commit ba0b93c into godotengine:master Aug 29, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@SelfDevTV
Copy link

SelfDevTV commented Feb 5, 2025

I found a workaround in the meantime for 4.3

// will stop the Autoscroll (or incrase / descrease it) and 
// will save the position it was at and put it back, so it transitions smoothly. 

Vector2 pos = p.Position;
Autoscroll = Vector2.Zero;
Position = pos;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants