Game Development Reference
In-Depth Information
Add this script to the
EnemyDeathFX
Prefab and set the
Sort Layer String
field to
ParticleLayer
. Go ahead and play the game again now to watch those particles
fly in front of the other objects.
Finally, if you want a solid color background to your scene, you don't need to worry
about adding a colored plane or anything. Simply select the
Main Camera
object,
and in the
Inspector
panel, look for the
Background
field in the
Camera
component.
Adjust the color there as per your need. For the example game, we made this color
a nice sky blue with the following values:
R: 128
,
G: 197
,
B: 232
, and
A: 0
.
The one thing you may notice we're missing is something at the bottom of the scene.
Here's a nice little challenge for you. We've given you a
Lava
sprite. Now, add in a
lava layer of parallax sprites in the foreground using all the info you've read in this
chapter. You can do this!
Let's score!
One of the most important elements to a game is being able to track progress.
A quick and simple way to do this is to implement a score system. In our case,
we will have a score that increases whenever you defeat an enemy.
Now, Unity does have a built-in GUI system. However, it has some drawbacks,
which will be discussed in detail in
Chapter 6
,
The Finishing Touches
. With this in
mind, we won't be relying on Unity's built-in system. Instead, we are going to create
objects and attach them to the camera, which in turn will allow us to have a 3D GUI.
Pro tip
If you want to use what this author believes is the best UI system for
Unity, purchase a license for NGUI from the Unity Asset Store. I'm not
the only one to think it's the best; Unity hired the NGUI developer to
build the new official UI system for Unity itself.
Let's build out some GUI elements:
1.
Create a
3D Text
object by navigating to the menu item
GameObject
|
Create
Other
; name it
Score
. Make it a child of the
Main Camera
GameObject
and align it such that it sits in the top-left corner of the screen.
2.
Set its position to
X: -6.91
,
Y: 4.99
,
Z: 10
to get this effect.