How to make background follow viewport

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tlz4320

I want to make a complex background which composed by several types of elements.
And one of elements I want is placed in the position relative to viewport, and could also scroll. For example, there is a robot always at the background of player, no matter where player goes.
I found parallaxbackground have option Follow Viewport, but I didn’t find any useful information about how to use it.
And importantly, at game starting, the viewport will be generated in a random position. So I don’t know how to make an element following viewport. Therefore, I can’t just change motion scale to achieve it.
Hope someone have experiences of that. Thank you!

i think if you set the motion to 0 for the parralax background, then it won’t move at all, meaning that if you move the camera (viewport) it will appear like it’s following the viewport compared to other backgrounds who move relative to veiwprot moving

godot_dev_ | 2023-06-25 13:41

You can use a separate CanvasLayer for that. Just let the “Follow viewport” disabled.

zeludtnecniv | 2023-06-25 14:25

thank you! I think I misunderstand the parallaxbackground function.

tlz4320 | 2023-06-26 04:02