Creating Sweet Particle Effects in GMS2

GM Version: 2
Target Platform: Windows/Mac
Download: N/A
Links: https://refreshertowel.games/2020/08/04/tutorial-particle-effects-in-gml/

Summary:
Learn how to create your own unique and interesting particle effects like this:


Tutorial:
Tutorial can be found here: https://refreshertowel.games/2020/08/04/tutorial-particle-effects-in-gml/



Here's Part 1 of 4:

Download the .yyz project file and import it into GMS2 (File > Import Project > Select the sweet-particle-effects.yyz file wherever you downloaded it to) to have easy access to the code and mess around with the particles yourself. Please note, I have altered some of the particle settings a little bit for the project file, to make them display better. Here’s a preview of it:



Part 1: Making your first particle

First, let’s see what the wormhole particles look like (after being embiggened somewhat):


So, first things first, what do we need to start creating particles? We’ll need a particle system. Let’s get that going. Open up the Create Event of the object you want to spawn the particles in and type in:

Code:
// ** Particle System: wormhole_ps_upper **
wormhole_ps_upper = part_system_create();
part_system_layer(wormhole_ps_upper ,layer);
part_system_automatic_draw(wormhole_ps_upper ,false);
Now, what we’ve done there is create a particle system called wormhole_ps_upper (I often create two separate particle systems, one to be drawn below the instance and one to be drawn above, which is why there’s the _upper postfix on there, but we don’t need two for this effect). Then we make sure the particle system is on the correct layer (setting it to layer simply makes sure the particle system is on the same layer as the instance creating it) and finally, we cancel automatic drawing of the particle system. This is because it gives you a little more control over exactly which depth the particles will appear. A particle system is necessary in order to create particles.


Now we’ll need to setup one particle emitter (the actual wormhole particles can be created without an emitter, but the line connecting the two needs one).

Code:
// ** Particle Emitter : wormhole_connect_emit **
wormhole_connect_emit = part_emitter_create(wormhole_ps_upper);
That’s nice and simple, just creating a particle emitter called wormhole_connect_emit and linking it to wormhole_ps_upper.


So far, we haven’t actually created any particles. That’s about to change. Let’s create our first particle:

Code:
// ** Particle : wormhole_part **
wormhole_part = part_type_create();
Now let’s mosey on over to the Step Event and add in a quick bit of code to create those particles in-game:

Code:
part_particles_create(wormhole_ps_upper, mouse_x, mouse_y, wormhole_part, 10);
And then pop open the Draw Event and enter this code to get the particles to draw:

Code:
part_system_drawit(wormhole_ps_upper);
As a side note, the reason that I manually draw the particles is because you can then position exactly where the particles will be drawn, layer-wise. For example, I could do this:

Code:
draw_sprite(sprite1,0,x,y);
part_system_drawit(wormhole_ps_upper);
draw_sprite(sprite2,0,x,y);
And the particles will be drawn above sprite1 and below sprite2. If you didn’t want to do this, you can just remove the line part_system_automatic_draw(wormhole_ps_upper ,false); from the Create Event and the particles will automatically draw themselves.


Run the game and tada! We now have particle effects. But they look pretty damn bad:


We have to give the particle some properties to make it look better...

Continue on with Part 2
 
Last edited:

GDS

Member
Dudeeeee sweet particles there!
I wish i could find this kind of high quality content on the marketplace
You should add a few more particles and sell this!
 
@GDS Hey, thanks a lot for the kind words =) Perhaps I'll get around to making a high quality particle pack type thing at some point in the future, but I'm a little too busy right now. However, most of my secret particle techniques are already spilled inside the tutorial itself, hahaha. Just a matter of taking the disparate ideas\techniques and piecing them together into what you picture inside your head.
 
  • Like
Reactions: GDS

Bart

WiseBart
This is great stuff indeed.
Those part_particles_create tricks are particularly interesting. I never considered doing it like that myself.

What I'd personally love to see is a follow-up tutorial on very precise control and 'exact' particle trails.
Create some particles with given speed, life, etc. Then figure out the location where they'll get destroyed.
Not sure if you have any other tutorials planned on this subject, though. Just a suggestion :)
 
Top