Jul23
2014

By: Elyse                Categories: BooksGames

We are going to create a simple but elegant particle system in Unity. To do this, we will create a game object with a Particle System component attached, and then use Unity’s Shuriken editor interface to customise that particle system to our requirements. Specifically, we will create a trail of ‘magical dust’ – something that could come from a magic wand, or from a spell book, or from any similar spell-casting entity. Though the system itself will be ‘simple’ it will nonetheless use a wide range of Shuriken features, demonstrate the power of the editor and equip you with the crucial knowledge you need to build your own systems for your own projects. Like many issues in game development, there is no ‘single correct way’ to create and configure a particle system. For this reason, don’t be afraid to experiment and to deviate from what I am creating here, especially if you prefer your edits and amendments. The basis to work on is: if it looks right, then it is right. So let’s get started.

1) Create an empty Unity project and save it, naming the current scene. Details on how to do that can be found in Chapter 1. Following this humble beginning, let’s import some graphical assets that we can use for creating our particle system. To import these, select Assets > Import Package > Particles from the main application menu. From the Import Dialog, accept the default values and click the button Import to add the assets to the current project in the Standard Assets folder, viewable from the Project panel. It should be noted that these imported assets are not essentials or prerequisites for creating particle systems generally – particle systems can be created without them. Nonetheless, the imported assets do feature a range of convenient pre-made textures and materials that we will use here for creating our particle system.

2) Create a new Particle System object in the scene. This can be achieved in at least two main ways. The first method (the one-step method) is to select GameObject > Create Other > Particle System from the application menu. The alternative two-step method is to first create an empty game object with GameObject > Create Empty, and then to add a Particle System component to the object with Component > Effects > Particle System. Either of these two methods achieves the desired end result of creating an object in the scene with a Particle System component attached.

3) You should see that when the particle system is created and then selected in the scene viewport it will run automatically – that is, the particles will be in motion. Further, a Particle System panel will appear at the bottom-right side of the viewport window in the Scene tab, showing a range of playback controls for the selected particle system. The Object Inspector also shows a range of editable properties for the selected particle system, listed and arranged under the Particle System component – the grey horizontal tabs in this component can be clicked on and expanded to reveal more options. Although it is correct to call the attached component a Particle System component, the menus, tools and options available from this component are generally termed the Shuriken editor. The fact that a separate name has been coined here signifies the extensiveness and comprehensiveness of the tools and options available for editing particle systems. If you prefer to view the properties of the Shuriken editor in a separate and dedicated window, as opposed to inside the Object Inspector, you can click the Open Editor button at the top right-hand side of the Particle System component. See Figure 6.2

Figure 6.1 Creating a new Particle System object in the scene with GameObject > Create Other > Particle System

Figure 6.2 Opening the Shuriken editor in a separate and dockable window

4.) The options of the Shuriken editor are arranged into tabs or panels, each with a unique heading. Only the main, overarching options are shown by default: others can be revealed by clicking the horizontal tabs. These tabs include: Emission, Shape, Size over Lifetime, External Forces and Collision. Figure 6.2 demonstrates the main options of the particle system, ranging from Duration to Max Particles. These options control the particle system overall, as we shall see. To get started, let’s tweak some options: change the Start Speed value from 5 to 2 and change the Start Color from White to Red. Observe the real-time result in the viewport – the particle system should change immediately. If it doesn’t change, check that the system is not paused from the Particle Effect panel in the viewport. If the leftmost button of this panel is listed as Simulate rather than Paused, then the system is paused. In this case, click the Simulate button to preview the particle system in the scene viewport. It should be noted that the Particle Effect panel controls only the playback of the system for previewing in the viewport, not the playback of the system during the game. For this reason, the settings of Particle Effect panel will not affect the particle systems when shown in Play mode.

Figure 6.3 Previewing the particle system in the Scene viewport

Excerpt from Unity 4 Fundamentals by Alan Thorn © 2013 Focal Press an imprint of Taylor & Francis Group. All Rights Reserved.

No Comments

No Comments

Tell us what you think!