Reader small image

You're reading from  Unity Game Development Essentials

Product typeBook
Published inOct 2009
Reading LevelIntermediate
PublisherPackt
ISBN-139781847198181
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Will Goldstone
Will Goldstone
author image
Will Goldstone

Will Goldstone is a longstanding member of the Unity community and works for Unity Technologies as a Technical Support Associate, handling educational content and developer support. With an MA in Creative Education, and many years experience as a lecturer in higher education, Will wrote the first ever Unity book, the original Unity Game Development Essentials, and also created the first ever video tutorials for the package. Through his sites http://www.unity3dstudent.com and http://learnunity3d.com Will helps to introduce new users to the growing community of developers discovering Unity every day.
Read more about Will Goldstone

Right arrow

Chapter 9. Finishing Touches

In this chapter, we will take our game from a simple example to something we can deploy, by adding some finishing touches to the island. As we have looked at various new skills throughout this book, we have added a single example at a time. In this chapter, we'll reinforce some of the skills we have learned so far, and also look in more detail at some final effects that we can add that aren't crucial to the gameplay — which is why it is best to leave them until the end of the development cycle.

When building any game, mechanics are crucial — the physical working elements of the game must be in place before additional artwork and environmental flair can be introduced. As in most cases, when building a game, deadlines will be set either by yourself, as part of an independent developer discipline, or by a publisher you are working for. By keeping the finishing touches at the end of the development cycle, you'll ensure that you have not lost any time working on getting...

Volcano!


For this next step, ensure that you have the Island Level scene open in Unity. If you have not, then open it now either by double-clicking on the Scene file in the Project panel, or by going to File | Open Scene and then selecting it from the Assets folder. Scene files are easy to spot, as they use the same icon as the Unity editor itself the Unity logo.

In Chapter 2, we built an island terrain with the terrain editor, including a corner of the island dedicated to a volcano mouth. To make this volcano seem a little more realistic, we'll add a plume of smoke and a mono-clip audio source to create a proximity-based sound of the volcano bubbling with molten lava. By adding both the audio and visual element, we'll hopefully achieve a more dynamic and realistic feel to the island and maintain player immersion in our game.

Begin by creating a new particle system in Unity by going to GameObject | Create Other | Particle System. This creates a new particle system called Particle System in...

Coconut trails


Next we'll add some flair to our coconut shy game by adding light trails to our coconut prefabs. By doing this, when the player throws them, they'll see a trail of light following the trajectory of the projectile, which should give a nice visual effect.

Editing the Prefab

To implement this change, we'll need to return to our coconut prefab from Chapter 6, as the Trail Renderer component we will use must be attached to this object. Open the Prefabs folder in the Project panel, and locate the Coconut Prefab asset. Drag it into the scene so that we can work on it — assets can be worked on directly from their location in the Project panel, but in order to preview and test the effect we're creating, it is best to drag them to the scene, and see what we're doing "in action". Remember that by pressing F with your cursor over the Scene view, you can zoom straight to the location of the selected object.

Trail Renderer component

To add the component, ensure that the Coconut Prefab is...

Performance tweaks


In this section we will look at ways in which you can boost the performance of your game as an end product. Also known as optimization, this process is crucial to do once you have ensured that your game works as expected.

Camera Clip Planes and fog

To add a nicer visual appearance to our island, we'll enable fog. In Unity, fog can be enabled very simply and can be used in conjunction with the Camera's Far Clip Plane setting to adjust draw distance — causing objects beyond a certain distance to not be rendered. This will improve performance. By including fog, you will be able to mask the cut-off of rendering distant objects — giving a less clunky feel to exploring the island. We discussed Far Clip Plane settings in Chapter 3 when we deconstructed the First Person Controller. Now, let's adjust the value of the far plane to improve performance by cutting down the distance at which objects are still rendered by the camera.

  • Expand the First Person Controller parent group by...

Instructions scene


To finish our game, we'll complete the menu we made in Chapter 8 by creating the Instructions scene for the user to read. In this, we'll implement some animation using scripting, and we'll learn a new command that we haven't utilized yet called linear interpolation, or lerp for short.

As our Instructions scene should mimic the rest of the menu, we'll start with the Menu scene as a basis. Before we do this, however, ensure that the Island Level scene is saved by going to File | Save Scene. Duplicate the Menu scene by selecting it in the Project panel and using the keyboard shortcut Command + D (Mac) or Ctrl + D (PC).

This will duplicate the Menu scene, and give it the name Menu 1, rename this Instructions, and open it by double-clicking on its icon now.

Adding screen text

We'll need to write our instructions for the player on this screen, so we'll utilize a GUI Text object for this purpose. Go to GameObject | Create Other | GUI Text. This creates a new object with a GUI Text...

Island level fade-in


In order to ease the player into the environment when they enter the game, we'll create a fade-in at the start of our actual game level using a GUI texture that covers the screen and is faded out over time using the Lerp technique we have just learned.

Double-click the icon of the Island Level to open that scene. Now, in the Volcano folder you imported earlier, you'll find a texture file called white. This texture, a flat white color created in Photoshop, is of size 64x64 pixels; this may sound rather small to cover the screen but as it is simply a flat color, it needn't be large — we will simply stretch it to the size of the screen.

Select the texture now and in the Inspector, deselect Generate Mip Maps in the Texture Importer component to stop Unity from rendering smaller versions of it for 3D use then press the Apply button at the bottom to confirm the change. We will use this texture with further UnityGUI and Lerp scripting to stretch it to full screen and fade...

Game win notification


As a final finishing touch, we'll tell the player that they have successfully won the game when the fire has been lit, as this is the goal of our game.

Open the PlayerCollisions script in the Scripts folder of the Project panel, and scroll to the bottom. The last function in the script is lightFire() and into this we'll add some more commands before its terminating right curly brace. Move down a couple of lines from the current last line:

Destroy(GameObject.Find("matchGUI"));

And place in the following commands:

TextHints.textOn=true;
TextHints.message = "You Lit the Fire, you'll survive, well done!";
yield new WaitForSeconds(5);
Application.LoadLevel("Menu");

Here we're switching back on our TextHints GUI from earlier, and sending the message "You Lit the Fire…" as the string of text to display on screen. We then use a yield command to halt the script for 5 seconds, and then load the Menu level of the game, so that the player may play again.

Now press the Play button,...

Summary


In this chapter, we have looked at the various finishing touches for your game. The visual effects, lighting, and animation discussed here only scratches the surface of what you can do with Unity, but while Unity makes it easy to add these polishing features to make your game really stand out, it is crucial to keep in mind that they should only be considered once your project's gameplay is honed — finishing touches are a great way to complete your project, but the playability should always come first.

Now that we have completed the game, we'll spend the next chapter looking at building, testing, and rebuilding, and the implications of deploying your game. We'll also take a look at further optimizations for your game and discuss getting your game seen as an independent developer.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Unity Game Development Essentials
Published in: Oct 2009Publisher: PacktISBN-13: 9781847198181
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Will Goldstone

Will Goldstone is a longstanding member of the Unity community and works for Unity Technologies as a Technical Support Associate, handling educational content and developer support. With an MA in Creative Education, and many years experience as a lecturer in higher education, Will wrote the first ever Unity book, the original Unity Game Development Essentials, and also created the first ever video tutorials for the package. Through his sites http://www.unity3dstudent.com and http://learnunity3d.com Will helps to introduce new users to the growing community of developers discovering Unity every day.
Read more about Will Goldstone