Making decent-looking projectiles in Unity is dead simple. Creating beautiful projectiles (rather than simply non-ugly ones) is another topic entirely, but we won’t be talking about that today.
Here’s an example of some projectiles made with the method that I’ll be teaching. Ignore the blue projectile since that one is, indeed, quite ugly (this is due to the texture – you’ll find that once you get the basic technique down, the aesthetic quality of your projectile is largely determined by your choice of texture).
The recipe is straightforward:
- Make a texture for your projectile in the shape of your projectile using a program of your choice. Have semi-transparent areas in the texture, particularly around the edges, so that it’ll glow when additively blended. Here’s the texture that I used for the orange and green projectiles in the above video:
- Create a stretched billboard particle system and have it use your texture. For maximum glowy goodness, you’ll either want to instantiate several copies of the particle and let them additively blend naturally (the naive method), or just write a shader for your particle that simulates additive blending via multiplication (slightly less naive). If you don’t additively blend, then you run the risk of your projectile not glowing enough, especially if you tint it with color since that will naturally darken it. At this point you might be thinking that a particle system is overkill, and you’re right – if you want to optimize things, just roll your own stretched billboard and additive blending and do away with the particle system entirely.
- Create a script that launches your projectile (setting its velocity, adding a force, whatever method of motion you prefer).
- (Bonus Step): Add some trails, sub-emitters, bloom, and other juicy goodness.
Using stretched billboard is a simple way to make sure your particle looks right from any angle and is oriented in accordance with its velocity. Using additive blending and bloom gives it that glowy goodness that any self-respecting particle should have.
With this technique you can make all kinds of projectiles: lasers, magic missiles, fireballs, you name it. Simply switching the texture that you use for the projectile can change it completely, not to mention the ridiculous amount of variation you can introduce via shaders, additional particle systems, etc.
Now go crazy, kids.