Creating a Particle Effect for Damage

Now that we know how to create particle effects, we should try hooking one up to the player’s hit reaction. This will require us to create a new particle system, attach it to the player, and call it from code.

Let’s get started by crafting the effect itself. We’ll make use of the star texture again, albeit in a slightly different way. When the player’s hit reaction is called, we’ll throw a small spray of spinning stars up and out behind the player. Just for fun, we’ll have them increase in size and shift in color as they go.

1. Use GameObject > Create Other > Particle System to create a GameObject with a Particle System Component.

2. Select a recognizable icon, such as a purple diamond, so that we can quickly ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.