Connecting main scene background to movement in a viewport

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

I have a main 2D scene with a zoom in of a ship and a zoomed in space background. In a viewport inside that scene I have the spaceship zoomed out with a camera2D following it in front of a zoomed out space background. Is there any way to make it appear as if the former background is synced up with the latter so that flying the spaceship/moving the camera in the viewport causes the background in the main scene to move appropriately?

:bust_in_silhouette: Reply From: MisterMano

Sounds like you’ll want to use the ParallaxBackground node and leave both backgrounds you have as children of it.

Basically, you add a ParallaxBackground node to the scene, then a ParallaxLayer. If you want the background to move at the same speed as the camera, leave the ParallaxLayer’s Motion → Scale values at 1. Lower numbers will make the background move slower, as if it was farther away.

The ParallaxBackground can have N ParallaxLayers, each with its own parameters and textures.

This video will probably help you understand it better: https://www.youtube.com/watch?v=7-zDftycdw8