Flamethrower Tutorial – No Coding Required!

Flamethrower Tutorial – No Coding Required!

Flamethrowers, acid guns and stasis guns (spray weapons) are one of the most used guns in shoot ’em ups, so i made a little tutorial to help everyone who’s new to Unity and Shuriken particle system.

Sprites

This one’s quite easy, i use a neat little program called Aseprite for pixel art, you can find it on Steam.

Aseprite Spritesheet

I made a small sprite sheet we will be using for our flamethrower, in this case it’s 64 pixels wide and 8 pixels tall. Use the Grid Settings function in Aseprite to nicely position your sprites in the middle of the cells.

Save it and import it in Unity.

Spritesheet import settings

Uncheck the Generate Mip Maps field since we don’t need those, and change the Filter Mode to Point so your sprites don’t get antialiased, we want clean and crisp graphics.

For using the sprite sheet in Shuriken, we need to make a material out of it. In your project view, click Create, then select Material. In the material inspector, select the Particles/Alpha Blended for the shader so you can use it in your particle system.

Material Inspector

Ok, it’s time to create our flamethrower! Create an empty object, in the inspector click Add Component and select Particle System. You’ll get the basic Particle System with white balls floating all around, but don’t worry, it will be balls of fire in a few minutes.

The first thing we’re gonna set up is the Renderer. All you need to do is simply drag and drop the material we made into the Material field and that’s it for this component of the Particle System.

Particle System Renderer

Next thing to set up is actually rendering the sprites from our sprite sheet instead of default Shuriken particles. We will do that in the Texture Sheet Animation component. Turn it on, set the X value to 8 (since we have 8 horizontal sprites, remember?) and leave the Y value set to 1 because we only have one row. We only have one row, so selecting Whole Sheet or Single Row in the Animation field won’t have any impact, but have that in mind when using multiple rows sprite sheets. We want our nice little sprites to be rendered in order they have been drawn in, so the smallest particles are renderer at the end, so leave the Frame over Time curve set as it is.

Particle System Texture Sheet Animation

We want our particles to be able to collide with enemies, so check the Collision field, and set the Collision Mode to World/2D. If you want it to collide only with certain layers, you can set it up under Collides With field. Our enemies are under Enemy Layer, so we selected that.

Particle System Collision

Shape component of the Shuriken determines the shape particles will move in. We’re making a flamethrower here, which disperses over time in a cone shape, so we will select Cone under Shape field, and adjust the Angle and Radius fields accordingly. Angle is, well, angle of the cone, you can play with it and make a wider or more narrow flame spray, and the Radius determines the radius of the cone shape. What does that mean? It means when we set it to the lowest possible value, in this case 0,01, the particles will emit from a single point, just what we need.

Particle System Shape

Let’s get to the main component of the Shuriken, the Particle System itself. Check the Looping box as we want our flamethrower to be turned on always. When it is looping and inserted into the scene view, you can always see it active and tweak it. You can use it in a looping state in a game too, simply make a particle system activate by pressing the fire button, and deactivate by letting it go.

We want our weapon to fire as soon as we press the button, so we’ll set the Start Delay to 0.

Start Lifetime is the amount of time the particle will live. To add a bit of variety to the flame spray, click on a small triangle on the right of the Start Lifetime box and instead of Constant select Random Between Two Constants. This will make some particles disappear sooner or later that the other ones making the flame spray look more realistic. We want a more focused spray, so we won’t set those constants too far apart. Same thing goes for Start Speed. It determines the start movement speed of the particle (which can be adjusted according to its lifetime) and it can help us make our spray more realistic. If you want a more focused spray, keep the constants near, if you want it wild, make them further apart.

We want our flame particles to start small and spread, so we will set the Start Size to tiny 0.1.

Simulation Space is set to World so the particles move on their own. If you set it to local, the emitted particles will follow the flamethrower movement, which we don’t want.

You can also limit the Max Particles number, but our flamethrower won’t be using many, so you don’t have to worry about it.

Particle System Main Settings

Under the Emission component you can set how many particles will be generated in a certain amount of time. We want a rich spray, so we set it to 100. If you’re planning to make a longer or faster spray, you can increase the amount, or decrease it if you want a short spray that won’t look cramped.

Particle System Emission

The final touch is Size over Lifetime component. Though we made our sprites smaller at the end of the sprite sheet to simulate the diminishing of the flame particles, some fine tuning is also usually needed, so we made a nice curve at the end of the lifetime of the particle so it nicely fades away.

Particle System Size Over Lifetime

Particle System Curves

There you have it, you own little pal ready to spray! I made the spray a bit bouncy, but you can turn it off by setting the Bounce value under Collision component to 0. Enjoy!

ezgif.com-video-to-gif

Comments are closed.