Game Development Reference
In-Depth Information
Done? Good. Now we can move some sprites. Import the sprites from
Sprites\
ParallaxScenery
. Start placing sprites in the three layer containers you created
earlier. For the hills you want to be closer, place the sprites in the
_NearHillsLayer
container; for the hills you want to be further away, place the sprites in
_
FarHillsLayer
; and place the clouds in the
_CloudLayer
container. The following
screenshot shows an example of what the layers will now look like in the scene:
Pro tip
Is this the absolute, most efficient way of doing parallax? Somewhat;
however, it's a bit hardcoded to only really fit the needs of this game.
Challenge yourself to extend it to be flexible and work for any scenario!
Parallax layer ordering
Wait, you say that the objects are layered in the wrong order? Your hills are all mixed
up with your platforms and your platforms are all mixed up with your hills? OK,
don't panic, we've got this.
What you need to do here is change the
Order in Layer
option for each of the
parallax sprites. You can find this property in the
Sprite Renderer
component.
Click on one of the sprites in your scene, such as one of the clouds, and you can
see it in the
Inspector
panel. Here's a screenshot to show you where to look: