Creating particle effects using Shuriken

From Unity 3.5 onwards, much more impressive effects can be created using particle systems. Many effects which used to need scripting can be achieved entirely through the Shuriken particle system settings.

Getting ready

It is useful to review important properties and the parameter value selection methods of Unity particle systems before actually trying to work with them in the editor itself.

Some of the fundamental properties of particle systems include the following:

  • Energy: How long a particle will "live" until it is destroyed
  • Looping: Whether the entire population of particles will be recreated again once the last particle has "died"
  • Speed, direction, and rotation: Each particle has its own transform, and when a new particle is created the particle system determines (from the settings you have chosen) that particle's direction and speed of movement and any rotation

In addition, it is important to understand the different methods that values are chosen for particle properties:

  • Constant: The same value for all of the particles
  • Curve: How the values will change over the duration of each cycle of the particle system (for example, particles start small and get larger over time)
  • Random number between maximum and minimum constants: Values are randomly chosen from the same range over each cycle of the particle system
  • Random number between two curves: This allows the range of values from which values are chosen to change over the duration of each cycle of the particle system

    The following screenshot shows two particle-size curves, that ensures particles start small (between 0.0 and 0.2), and get larger over the 3 second (x-axis) cycle length. However, the size of particles is random between the two curves (a value always chosen in the "red" zone), so towards the end of the cycle, particles will be a random size between 1.0 and 2.8:

    Getting ready

How to do it...

To create a particle effects using Shuriken, follow these steps:

  1. Create a new Unity project and import the Particles Unity package.
  2. Create a new particle system.
  3. Reset the particle system to its defaults by choosing Reset from the component's Context menu in the Inspector.

    Note

    To view the Context menu, either right-click on the component's name, or click the tiny gear icon at the top-right corner of the component's section in the Inspector view, as shown here:

    How to do it...
  4. Switch on (check) Wireframe for the Render section of the particle system, shown below:
    How to do it...

    Note

    Wireframes can aid in understanding the position and movement of particles by drawing a blue bounding rectangle around each particle in the Scene window, and a white bounding rectangle around the complete set of particles of each frame.

  5. Display the Renderer properties (double-click the darker grey title bar) and change the renderer's Material parameter to SoapBubble:
    How to do it...

    Note

    You'll find materials from the Unity particles package located in the Project folder as follows: Standard Assets | Particles | Sources | Materials.

  6. Set Start Speed to 2 and set Start Size to a random number between the constants 0.2 and 1:
    How to do it...

How it works...

You've created a particle system which emits differently-sized rising particles showing a soap bubble. They move relatively slowly (since you set Start Speed to 2). Each particle shows a soap bubble, since you set the renderer to use a material that had a soap bubble texture image. The bubbles vary in size since you set Start Size to be a random number between 0.2 and 1. They float upwards because the system is rotated by -90 on the X-axis (the default settings you ensured by clicking Reset).

There's more...

Here is some information on how to fine-tune and customize this recipe.

Scrubbing back and forward through the particle animation

A nice feature to easily review and ensure that the particle system's behavior is as desired is the ability to "scrub" (move back and forward through the animation). This is achieved by clicking and dragging left or right on Playback Time text in the particle Preview Panel in the Scene window:

Scrubbing back and forward through the particle animation

Learning more from the Unity documentation

Unity particle systems with Shuriken can be very powerful and therefore complex components of games. The Unity manual provides several pages dedicated to introducing and describing this system. You'll find the ParticleSystems.html file in the /Documentation/Manual/ section of the Unity website, and also in your own computer's Unity application folder.

Adding effects through Particle Effect

Opening the Window | Particle Effect menu and clicking the plus symbol adds additional particle sub-systems. Complex effects can be created through particle systems working at different times with different settings.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.22.23