Creating Parallax-scrolling backgrounds

In 2D games that are entirely sprite-based, you can make use of parallax scrolling to give the illusion of depth. Parallax scrolling causes sprites to move across the screen at different speeds as the camera pans across, and is a common technique in 2D game development.

Following on from the previous tutorials, let's make the ParkBackground sprite appear distant, by adding the Parallax 2D script component to its GameObject:

This scene only deals with sideways-scrolling, we only need these Parallax sprites to scroll in the X direction, so checkScroll in X direction?. The Offset float is best left at zero, trial and error in-game will help you find a correct value if one is required.

The important field to set is the Depth value. Positive values make the associated sprite appear further away from the camera, while negative values make it appear closer - and the larger the value's magnitude, the greater the effect. A depth of 5 should work well for the ParkBackground sprite.