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 7. Particle Systems

In this chapter, we will take a look at some of the rendering effects available to you as a Unity developer. To create more dynamic 3D worlds, rendering effects outside of simple materials and texturing are used to simulate, and often accentuate, the features of the real world. Many 3D games have adopted visual conventions of camera-captured imagery, introducing such effects as lens flares and light trails as part of a simulated viewpoint which in real terms would never witness such effects.

We have already taken advantage of the lens flare rendering effect in Chapter 2, where we utilized a Sun lens flare on the light component of our main directional light. In this chapter, we will look at more versatile effects that can be achieved by using particle systems within your 3D world. Games use particle effects to achieve a vast range of effects from fog and smoke to sparks, lasers, and simple patterns. In this chapter, we'll look at how we can use two particle systems...

What is a particle system?


A particle system is referred to in Unity as a system — rather than a component — as it requires a number of components working together in order to function properly. Before we begin to work with the systems themselves, we need to understand the component parts and their role in the system.

Particle emitter

Within any particle system, the emitter component is in charge of instantiating individual particles. In Unity, there is an Ellipsoid Particle Emitter and a Mesh Particle Emitter available.

The ellipsoid is most commonly used for effects such as smoke, dust, and other such environmental elements that can be created in a defined space. It is referred to as the ellipsoid because it creates particles within a sphere that can be stretched to accommodate the system.

The mesh emitter creates particles which are tied directly to a 3D mesh and can either be animated along vertices of a mesh or simply emitted upon the points of the mesh. This is more commonly used when...

Making the task


Our existing game consists of a task for the player to complete in order to enter the outpost — they must collect four batteries to power the door, one of which has to be won by winning the coconut shy game we added in the previous chapter.

Currently, having entered the outpost, the player is met with a sense of disappointment — as there is nothing to be found inside. In this chapter, we will change that by adding a box of matches to be picked up by the player when they enter the outpost. We will then create our fire outside, which can only be lit if the player is carrying the box of matches. In this way, we can show the player a set of logs waiting to be lit, leading them to attempt to find matches by completing the tasks laid out (that is, opening the door).

To create this game, we will need to implement the following in Unity:

  • Locate an asset package, and add a log fire model to our scene near the outpost.

  • Create the particle systems for fire and smoke for when the fire is...

Testing and confirming


As with any new feature of your game, testing is crucial. In Chapter 9, we'll look at optimizing your game and ensuring that test builds work as they are expected to, along with various options for delivering your game.

For now, you should ensure that your game functions properly so far. Even if you have no errors showing in the console part of Unity (Command + Shift + C shows this panel on Mac, Ctrl + Shift + C on PC), you should still make sure that as you play through the game, no errors occur as the player uses each part of the game.

Press the Play button and play through the battery collection, coconut shy game, match collection, and fire lighting to ensure that all elements currently work. If any errors occur, then refer back to your scripting and check that everything matches the code listings in this book.

Note

If you encounter errors while testing, the Pause button at the top of the Unity editor will allow you to pause, play, and look at the error listed in the...

Summary


In this chapter, we have looked at the use of particles to give a more dynamic feel to our game. Particles are used in a wide array of different game situations, from car and spaceship exhausts to guns and air-vent steam, and the best way to reinforce what we have just learned is to experiment. There are a lot of parameters to play with and, as such, the best results are found by taking some time out of a project just to see what kind of effects you can achieve.

In the next chapter, we will take a look at making menus for your game, and this will involve scripting with Unity's GUI class, as well as using GUI Skin assets to style and create behaviors for your interfaces. The GUI class is a specific part of the Unity engine, which is used specifically for making menus, HUDs (Heads Up Displays), and when used in conjunction with GUI Skin assets, becomes completely visually customizable and re-usable. This is because Skin assets can be applied to as many GUI class scripts as you like...

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 AU $19.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