0 votes

I am attempting to update the scroll_offset.x value of a ParallaxBackground using the following code:

export(int) var scroll_speed: int = 1000
func _process(delta):
    scroll_offset.x = scroll_offset.x + scroll_speed*delta

(This approach is adapted from this response to a question about how to make a background scroll when the camera position is fixed).

No matter what value scroll_offset.x is initialized to, this code causes it to quickly converge to around -1334.724365 after which only the decimal values change (whereas it should continue to increase as far as I understand).

The ParallaxBackground has a ParallaxLayer child with Mirroring set to x = 960 and y = 1080 and motion scale set to x = 0.2, y= 0.2. That has a Sprite child with scale set to x = 2 and y = 2. The resource for the sprite is a PNG that is 960X540. I have tried importing it with Repeat Enabled, Mirrored, or Disabled, and none of those settings worked.

Setting scroll_offset.x to any fixed value works, including values much more extreme than what it appears to "converge to", but somehow incrementing in _process isn't working. What simple thing am I missing here?

Godot version v3.5.2.stable.official
in Engine by (73 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.