I really enjoy working with the Unity game engine. It is terrific as a 3D engine; but recently they have added 2D functionality. “Learning Unity 2D Game Development by Example” by Venita Pereira is a book that will help you understand how to use the new 2D aspects of Unity 2D. As with most Packtpub books the artwork, code samples, etc. are available on their website for download.
The book begins with providing information on where to download Unity 3D version 4.3.4. I completed the projects in the book with the current beta version (Unity 4.6) and everything worked just fine. Next you create a project and then the book discusses the interface with you including how to bring up the Animator and Animation components which you will need for some of the later projects in the book.
The next chapter discusses how to create a scene in Unity. It presents how to import sprites (graphics) and place them in a scene and then how to create a prefab from the sprites. Camera settings, setting a background and working with a grid are all explained. Chapter 3 is covers creating a 2D character in your scene. Unity’s animation system, Mecanim, is explained. How to import a sprite sheet; chop it into the various sprites which represent body parts, and then animate the resulting character is explained.
The next four chapters go into detail on how to create 4 different sorts of 2D games. The games types are: roguelike, classic arcade, endless runner and a physics game. A website location is listed where you can download the graphics for all the projects listed. The roguelike game chapter explains how to break up a spritesheet into its various sprites and then how to animate them. Randomly spawning enemies, programming your character to shoot an object and destroying objects are all part of this lesson.
The classic arcade game demonstrated is the one where you move your character along the bottom of the screen and random objects spawn from the top and drop down for you to try and catch. The chapter explains 3 common game mechanics: keeping score, a timer, and how to give your character more than one life. The chapter goes on to explain how display all of these on a HUD screen.
The endless runner chapter mostly discusses how to make a ninja character appear to be running endlessly. This is done by explaining how to create parallax scrolling in Unity. The chapter also explains how to use Unity’s particle effects to create puffs of dirt coming off the ninja as he is running.
The physics game chapter explains how to create a game using the Box2D physics engine that Unity provides. The example game provided involves shooting a cannon and having it knockdown planks on top of boxes. Scripts to do this are explained and how to extend the game is discussed.
The last chapter describes how to polish all the example games by adding audio, more cameras, multiplayer, and the ability to save and load. Then details are provided on how to deploy the game to the web. The book ends with a list of online resources where you can find more information on Unity.
Overall, I liked the book and enjoyed learning the ins-an-outs of programming and implementing the various sample game types. If you are new to Unity and especially if you are new to Unity 2D then I can easily recommend this book. Here is the link for the book