Author: Thomas Finnegan
Pub Date: 2013
Size: 13 Mb
In this book, we explore the ever-expanding world of mobile game development. Using Unity 3D and the Android SDK, we will learn how to create every aspect of a mobile game. Every chapter explores another piece of the development puzzle. Exploring the special features of development with mobile platforms, every game in the book is designed to increase your understanding of these features. We also finish the book with a total of four complete games and all of the tools we need to create many more. The first game that we make is Tic-tac-toe. This game functions just as the classic paper version. Two players take turns filling a grid with their symbols; the first to make a line of three wins. It is the perfect game for us to explore the graphical interface options that we have in Unity. By learning how to add buttons, text, and pictures to the screen here, we have all of the understanding and tools needed to add any interface that we might want to any game. The next game that we create is the Tank Battle game. The player takes control of a tank to drive around a small city and shoot targets and enemies. This game spans three chapters, allowing us to explore many key points of creating games for the Android platform. We start by creating a city and making the player’s tank move around, using controls that we learned about when making the Tic-tac-toe game. We also create and animate the targets that the player will shoot at. In the second part of this game, we add some lighting and special camera effects. By the end of the chapter, the environment looks great. In the third part of the game’s creation, we create some enemies. Using the power of Unity, these enemies chase the player throughout the city, and attack when they are close. The third game to be completed is a simple clone of a popular mobile game. Using the power of Unity’s physics system, we are able to create structures and throw birds at them. Knock down the structures to gain points, and destroy the target pigs to win the level. We also take the time to explore some of the specific features of a 2D game, such as a parallax scrolling background, and how they can be achieved in Unity. We complete the chapter and the game with the creation of a level selection menu.
2D games in a 3D world
Perhaps the most underrealized thing when developing games is the fact that it’s possible to create 2D-style games in a 3D gameengine such as Unity. As with everything else, it comes with its own set of advantages and disadvantages, but the choice can be well worth it for generating a pleasing game experience. The foremost of the advantages is that one can use 3D assets for the game. This allows dynamic lighting and shadows to be easily included. However, if using a 2D engine, any shadow would need to be painted directly into the assets and you would be hard-pressed to make it dynamic. On the disadvantage side is the use of 2D assets in the 3D world. It is completely possible to use them, but large file sizes become necessary to achieve the desired detail and keep it from appearing pixelated. Most 2D engines, however, make use of vector art that will keep the image’s lines smooth as it is scaled up and down. Also, one is able to use normal animations for the 3D assets, but
frame-by-frame animation is generally required for any 2D asset. Altogether, the advantages have outweighed thedisadvantages for many developers, creating a large selection of great looking 2D games that you may never realize were actually made in a 3D game engine. Now, we shall design another game by recreating the highly popular Angry Birds.
What just happened?
We did the initial setup for our 2D game. By changing our camera view to Orthographic, the view switches from a 3D game to a 2D one. We also created a ground and some trigger volumes for our scene. Together, these will keep our birds and anything else from straying too far.
What just happened?
We put into practice what we learned about particle systems to create trails for our space ship’s engines. Because they are children of the ship and simulate in world space, they move with the ship and trail off as one would expect.
Have a go hero – more trails
The enemy ships have engines too. Try adding trails to the enemy ships. Be careful about picking the local or world space to simulate in. Because the ships move to make it look like the player is moving, simulating in world space could have some unusual side effects.
If you gave the player a turbo boost effect earlier, it is time to add some extra effects to it now. Try changing the length of the trails when the player is boosting. Perhaps the ship taps into a special type of fuel when it boosts. If it burns a different color, then the trails would have to be a different color, or series of colors, when the player is boosting.
Putting it together
So far, we learned about audio effects and particle systems on their own. They each can add a lot to the scene, setting the mood and giving that touch of polish that sets a game apart. But there are many effects that cannot stand on their own as one or the other. Explosions, for example, are simply not that impressive unless you have both the visual
and auditory effects.
It is so much more satisfying todestroy enemies when they explode. It takes both a particle effect and the sound effect to make a proper explosion. We will start by creating an explosion prefab. Then we will update the player’s shooting to spawn the explosion when asteroids and enemy ships are destroyed.