Game Development Reference
In-Depth Information
Parallaxing
If we look at the 2D sample provided by Unity, the background is split into several
panes—each layered on top of one another and each moving at a different speed when the
player moves around. There are also other elements such as clouds, birds, buses, and taxes
driving/flying around, as shown in the following screenshot:
Implementing these effects is very easy technically. You just need to have the art assets
available. There are several scripts in the wiki I described earlier, but the one in Unity's
own 2D sample is the best I've seen.
Note
To see the script, just download the
Unity Projects: 2D Platformer
asset from
ht-
tps://www.assetstore.unity3d.com/en/#!/content/11228
,
and check out the
Back-
groundParallax
script in
Assets\Scripts
.
The
BackgroundParallax
script in the platformer sample implements the following: