Game Development Reference
In-Depth Information
The sprite object also introduced you to the concept of camera Layers where you discovered both
2D and 3D objects could be assigned and included in or excluded from a particular camera. 2D
objects, you found, are better suited to a camera with an orthographic projection. With multiple
camera layers to produce the final view, you learned that Clear Flags gave you a further means of
controlling what each camera renders.
Once in the Scene view, you found that the 2D objects had a new transform gizmo in the guise of a
rectangle with blue dots at the corners. You were able to perform the various transforms by watching
the cursor icons and dragging from different spots on the gizmo. While setting up a means to
animate the scale of the battery sprite's progress bar, you had a chance to animate its color using its
RGB values with Unity's Color struct.
With the addition of the “delivery” stork sprite, you got some practice with customizing pivot points
and learned how easy it was to let Unity generate an animated sprite from a sprite sheet. Getting
deeper into the topic, you were able to customize the sprite animation as well as use traditional
key-frame animation to move, rotate, or scale them. With the addition of the beak and bundle to
your stork, you made use of Sorting Layers to dictate the draw order between the various sprites
occupying the same camera layer.
To top off your 2D experience, you had a go at combining Unity's 2D physics system with the
traditional sprite and key-frame animation. You were able to make use of the 2D counterparts of
already familiar physics components, including Rigidbody2d. As you managed the 2D baby zombie
bunnies, you found it necessary to use the very powerful Physics2D.IgnoreLayerCollision to allow
or prevent interaction with the various other 2D objects. With the addition of a Physics2D Material,
you completed the chaos introduced by the hapless delivery stork.
As a takeaway from this chapter, you had a look at the concept of orthographic cameras and “pixel
perfect” sprite displays. You learned that there are pros and cons to using 2D elements and most
importantly, that there are several issues involved with authoring for different screen sizes and
aspect ratios.
Finally, while much of the chapter dealt with art assets, you also refined many of your existing
scripts to control and improve the user's experience. A couple of notable discoveries were modulus
math, which uses the remainder of a division operation to calculate rewards for your player, and the
requirement to expose variables to other scripts but not the Inspector with the use of internal rather
than public .
Search WWH ::




Custom Search