PANDEMONIUM - Balance
3D Maze Game for Android Device
Introduction
A First Person Shooter maze game intended for any android device and currently implemented and tested for Samsung Captivate.
This game has three levels with increasing level of difficulty. Each of the levels has a different theme and background score that befit the environment and help in building the ambience for the game. In total the game has 8 scenes which are as follows. The game was built
Framework
A framework was designed before the game development started.
Organization
The first level has a maze skeleton. The Game comprises of 8 scenes in total. The first scene is a Menu which has basic menu functionality. The second scene is an instructions page which has appropriate visual cues for navigation and playing the game.
The rest of the scenes are organized into 3 levels as follows.
Level 1
First level has just one scene and the time limit for its completion is 2 minutes. The only task it comprises is collecting as many coins as possible worth 100 points each and finding the way out of the maze. This level has a cartoony theme which is made evident by the textures used and the background score.
Level 2
Second level comprises of 2 scenes in total. The time limit for the completion of this level is 4 minutes. In the first scene it has wooden environment. The textures used look realistic due to the use of normal maps. It also has moving walls which would reduce score by 100
points every time it hits the player. The scene has two staircases beneath one of which there is a portal that leads to the next scene. The second scene has a wooden platforms connected with two staircases. Aim to collect as many coins as possible and go to the top of the tower and jump on the portal which would take us to the next scene.
Level 3
Third level comprises of 3 scenes. The time limit for the completion of this level is 6 minutes. The theme of this level is darkness and single headlight. It is meant to be spooky and this has been achieved by using appropriate lighting effects and the background score. The first scene introduces the theme with a simple maze with staircases. The second scene has criss-cross platform with moving fire which deducts 200 points every time we run into it. The third scene has teleporter which takes us from one small platform to other and also between scenes until we reach the goal.
Tools
This game is completely built with the unity game engine. Modeling tool Blender was also used to make certain models but none of the models have been used in the game as there were issues with importing some of them.
Unity 3D is one of the most complete game engines that is available today. It is very user friendly and has a lot of documentation. This engine speaks to game developers of all ranges, from beginners to the professionals. Its wide support group, varied tutorial projects and forums make it an exceptional tool to use. The best part is that there is a free version of the engine with innumerable features. Also, they now provide a free Pro trial version.
The unique features of unity that I would like to highlight are it lets the user build prefabs for his use.
Prefab
A Prefab is a type of asset -- a reusable GameObject stored in Project View. Prefabs can be inserted into any number of scenes, multiple times per scene. When you add a Prefab to a scene, you create an instance of it. All Prefab instances are linked to the original Prefab and are essentially clones of it. No matter how many instances exist in your project, when you make any changes to the Prefab you will see the change applied to all instances.
Particle Systems
Particles are essentially 2D images rendered in 3D space. They are primarily used for effects such as smoke, fire, water droplets, or leaves. A Particle System is made up of three separate Components: Particle Emitter, Particle Animator, and a Particle Renderer. We may use a Particle Emitter and Renderer together if we want static particles. The Particle Animator will move particles in different directions and change colors. We also have access to each individual particle in a particle system via scripting, so we can create your own unique behaviors that way if we choose.
The Particle system prefabs I have used for this project are -
Light Snow - This has been used in level 1. The light snow is attached to the camera. This is because since it is a first person shooter we intend to see this effect throughout the level it is very nice to have one particle system of the kind and attach it to the camera so that we always see the effect without hogging on the resources.
Dust Storm - This has been used in all the levels except 1. Again this has been attached to the camera due to the reason stated above.
Fire - This prefab has 3 particle systems within it. The inner core, the outer core and the smoke. This has been used in level 3.1, 3.2 and 3.3. In levels 3.2 and 3.3 a moving script has been attached to which would deduct 100 points from our total score every time we run into it.
Other than the above I have created custom particle systems for different purposes
1. Portal - Level up mechanism
2. Teleporter – Used in the last level to teleport from one place to another which is the only way to finish the game.
GUIStyle - This class contains all information for how a gui element should be rendered. It contains information for font, icon placement, background images, and spacing. It does not contain information for what it contains - just defines how any text rendered with this style should be displayed. It does not define what interactions can occur with the element, but defines the display settings commonly used in by the interactions.
The font that is used for displaying Time left, Score and other messages all have been rendered using GUIStyle.
Layers - Unity provides us with the ability to selectively render certain parts of the scene with the use of layers. Layers can be associated with cameras or lights based on our need. In this game I have only associated layers with the camera.
Cameras - There are two cameras in all scenes except the last scene. One is the camera attached to the player which comes as a part of First Person Controls Prefab and another added camera used for top view minimap of the maze. A camera gameobject comes with certain default settings for its parameters. The following table describes the paramter settings for two different cameras. (Only the parameters which differ have been mentioned in the table)
Explanation
Clear Flags - Color and Depth information needs to be stored in each camera when it renders its view. This information is stored in buffers and every time the camera renders more data keeps getting accumulated. Hence clear flags are used to clear these buffers. By default the value is set to Skybox. If we have no special skybox created for the scene the camera will render the default render settings. However in the first level I have created a cartoony skybox which goes with the theme.
Background - It is the color applied to the remaining part of the screen when all entities have been rendered. It is set to default for FPS and Minimap camera does not have it since we are rendering depth only.
Culling Mask - For the FPS camera we need to render all game objects. However in the minimap camera I need to render only the Maze skeleton and the FPS graphics. This has been achieved by doing the following.
1. Create a custom layer - E.g.: - Maze2 in my game
2. Add all your special objects to this layer.
3. In camera settings under culling mask select your custom layer.
* Normalized Viewport - Specifies where the camera will be drawn on the screen. we need to render the fps camera on the entire screen. However we need a very small minimap. Hence the viewport x, y, width and height co-ordinates have been set accordingly.
Depth - This specifies the order in which cameras are drawn. We need to draw the FPS camera first since it would cover the entire screen and hence its value is 0. The minimap camera needs to be drawn over the FPS camera and hence its depth value is set to 1.
Lights
Lights add color and life to the game. It is one of the most important parameters in a game. Unity 3D provides us with 3 different kinds of lights. They are
Point Light – Behaves like a light bulb
Directional Light – Behaves like sun where light comes from infinity
Spot Light - Illuminates an area in the form of a cone.
I have made use of Point Light and Spot Light in this game. These lights come with certain parameters that need to be tweaked carefully in order to achieve the desired effect.
Level 3 in the game required a headlight and that was got by tweaking the parameters of a spotlight. A headlight was achieved by Following are the differences in the parameters between the Point light and Spot Light. (Only the parameters whose values differ have been listed in the table)
Joystick
For Navigation on the device I have used the DualPads prefab that comes with Unity. It has two textures one for move and one for rotate. This prefab has the following components.
Left Touchpad - It is used for movement in the game. This gameobject is a guitexture. We can use the the default dotted line texture that comes with it or change it to suit our needs. I have chosen Joystick texture in this game and changed its color to red.
Right TouchPad- It is used for rotation in the game. This gameobject is a guitexture.. I have chosen Joystick texture and changed the color to blue..
The Player is attached with a First person control script. This script has two variables Left Joystick and right joystick which need to be assigned. We then need to drag and drop Left Touchpad on left joystick and right touchpad on right joystick.
The joystick script has a few parameters which need to be set for smooth navigation in the game. My settings are as follows.
Mini Map- There are minimaps available at the top right corner for the first two levels and first scene of the third level. This map has the Maze and the player on it but no obstacles or coins.
Physics
Unity has a range of physics components like Rigidbody, Character Controller and Static Colliders. This game has made use of Character Controller component and the static collider component. Every time a mesh is created in Unity a static collider is assigned to it by default. There are different colliders for objects of different shapes. A cube has a Box Collider, Sphere Collider, wheel Collider and so on. These colliders stop any mesh from passing through another mesh in the game.
Trigger
Unity provides a unique trigger mechanism in its game engine. In this game all level up mechanisms, score, and game end functionality have been designed by the use of these triggers. This is a parameter of the box collider which when checked makes the mesh act as a trigger. The Trigger can be set to work on enter or on Exit. Triggers have been mainly used for three purposes in this game. They are:
1. At the end of each scene destroy the player and load the next scene
2. On entry into a coin increase the score by 100 points
3. On Entry into the portal teleport it to a different location or a scene or end the game based on result desired.
Portals
The portals are made with particle systems. The particle systems have been modified with the different parameters available in its components which are Ellipsoid Emitter, Particle Animator and Particle Renderer to suit our needs.
Pause Play
The game has Pause/Play functionality available in each scene. There is red pause texture displayed at the top left corner of the screen at all times during the game. The following happens when this texture is touched.
1. The Game pauses.
2. Everything comes to a standstill.
3.The background music comes to a halt.
4. The texture gets replaced by Play texture.
Vice versa of the above happens when play is pressed.
Fonts
The Unity Engine comes with one default font - Arial. However it provides us liberty to import fonts and use them for our needs. I downloaded tens of fonts from 1001 Free Fonts and tried it within the game. Some of which are Arcanum, BullPen3D, dig, BurgerJoint, ccaps and so on. BurgerJoint font was the winner in the lot and hence it has been used to display all the text in the game. All display has a shadowed effect on each of it. This is created with the help of GUILabel.
Art
Art for this game has been created keeping in mind that it would be one of the means to convey the theme. Hence the texture selection has been made in such a way that it befits the scene and builds the ambience for the gameplay.
The first level was intentionally cartoony so that the player can just browse through the maze and collect some points. It creates a very light and happy atmosphere for the gameplay.
The second level was meant to have realistic looking textures. Hence the walls and the maze have been given different kinds of wooden textures. The floor has been given realistic looking tiled floor textures. The player can actually notice the depth on the textures. This has been achieved by using bump maps and normal maps.
Unity has a great way of dealing with textures. We can convert any texture into normal map within Unity. All we have to do is make a copy of the texture, select the image and select the 24 bit RGB format and enable Generate Normal Map in the Import Settings in the Inspector as shown in the figure.
The third level is meant to have an eerie theme and hence the textures have been chosen to suit the needs of the level. Most of the textures are dark and murky. Normal maps have been used even for these textures.
Other than these textures a few have been created for GUI of the game. Some of which are the menu screen, navigation screen and play/pause buttons. All these textures have been created using Gimp and photoshop. Also the textures which were found only have been modified using Gimp and Adobe Photoshop.
Sound
Sound for each of the level has been carefully chosen as it is the second most important ingredient for creating the ambience for gameplay. There are multiple sounds used in the game.
Unity provides a very easy nice way of dealing with sounds. We can attach as many different Audio Sources as we like in one scene but we should always have just one Audio Listener. The Audio Listener acts as a microphone-like device. It receives input from any given Audio Source in the scene and plays sounds through the computer/device speakers.
There are a lot of parameters that we need to pay attention to for proper audio throughout the game. Some of them are
Play on Awake - This needs to be turned off if we need not need to hear the sound at all times.
Loop - Needs to be turned on if we need the sound to keep playing over and over again.
Volume - Controls the volume of the Audio source.
Min Distance - This needs to be set to ensure that the intended sound is audible till the location of choice even if we move away from the source. It is nice to set it higher in a first person shooter game if the source is not attached to the camera/player.
In level 1 I have used a very pleasant happy sound that goes with the textures and the theme. In the second level the sound rumbling sound that goes with the ambience has been used. The third level has a very eerie background score playing throughout the level.
Other than these there are sounds to depict money collection and alarm that rings when there are less than 30 seconds remaining in the level.
User Manual
This is a 3d Maze game built for Android device.
The game starts with a menu screen which has 4 options. They are
1. NEW GAME
2. INSTRUCTIONS
3. CREDITS
4. EXIT
Touching the INSTRUCTIONS button takes us to the instructions screen. The instructions screen has the following:
1. Visual cue to Move
2. Visual cue to Rotate
3. Coins (Money) - Gives 100 points
4. Moving Wall - Deducts 100 points
5. Moving Fire – Deducts 200 points
Level 1
In the first level the user needs to find the way out of the maze. He also has to collect as many coins as possible to make a good score. There is a minimap at the top right corner of the screen. This helps the player to know where he is at any point in time.
The player needs to find his way to the exit. We can use the tiny red texture at the left hand corner at any point in the game to pause and play.
If he does not finish in time (2 minutes for this level) then a game over message is displayed.
The second level has 2 scenes. The first one has a slightly modified maze and moving walls which deducts 100 points.
The player has to avoid the moving walls and find his way to the portal that takes him to the next level.
The next scene has platforms and a tower connected with staircases. The player needs to balance his way through this level so that he does not fall. Falling would put in back on the previous level.
The player needs to jump into the portal to go to the next level.
The third level has 3 scenes. The first scene has introduces head light. It is a simple maze with very dark ambience.
The second scene is a platform maze with moving fire. Every time the player runs into the fire 200 points get deducted.
The Third scene has a 12 portals. The player has to find the right combination of portals to win the game.
Errors and Issues
The game involved a lot of technical issues.
Android Device - The device had to be upgraded to Android 2.2 (Froyo) to be compatible with Unity 3D. However after a week of use the device stopped working and had to be replaced. Also ran with issues with device driver. All the usb ports were not compatible with the Android device usb cable. All the cables would not work in the usb debugging mode.
Unity 3D - To push the game build to Android Device we need Unity Pro version. During the course of this game the license expired twice but Unity was kind enough to provide me with an extension for the Trial student license.
Bibliography
1. Unity: Penolope - http://unity3d.com/support/resources/tutorials/penelope.html
2. Unity 3D Documentation Manual - http://unity3d.com/support/documentation/Manual
3. Unity Scripting Reference - Scripting Overview - http://unity3d.com/support/documentation/ScriptReference/
4. Unity Answers - http://answers.unity3d.com/index.html
Resources
1. Unity 3D : http://unity3d.com/
2. 1001 Free Fonts - http://www.1001freefonts.com/
3. Textures : http://www.cgtextures.com/