The particle system
In this tutorial we show you how to use the particle system. Visual effects are important, and here we show you how to implement them.
1.0 – Exploring particle settings
For this tutorial we will assign the image of a particle, for that we have prepared a texture of small size. We will assign this image to our editor to create an object.
Let’s take a quick look at our particle panel by pressing the virtual PARTICLE MENU button.
This compact panel houses all the functions that GameMaker Studio offers us. Giving us the ability to create emitters, new transition particles and many more functions if we add to the equation our object created for this purpose.
1.1 – Assigning the controller object
The creation of particles is achieved thanks to the OBJECT COMPONENT SCRIPTING technique that we will talk about in advanced tutorials. You could say that this is your first custom object that uses this function creating a fantastic control system.
First of all, if we want to configure a particle system and visualize every touch-up we make, we must call an object.
In the image below we write the name of the object to call (“obj_particle_system”).
This does not make it run in the editor, it is the assignment that identifies in which object our asset will be transformed when the level begins.
DarkSpine can execute objects from the editor if it does not interfere with the proper functioning of the other utilities. To achieve this goal we will only have to press the virtual TO OBJECT button.
1.2 – Our settings panel
We already have a system working from our editor. Now our panel is dynamic, and in each modification we will see the result represented.
The list of configurable values is as follows:
- SPRITE: Assigns the image to be used as a particle and you can configure the following options:
- Animated: Activate this option if your particle contains a sequence of images.
- Strech: Activate this option to adjust the timeline between animation and the lifetime of our particle.
- ramdom: Choose a random image if you use a sequence of images.
- SIZE: Adjust the size of our particle and we can adjust the following values:
- Min: The minimum size of our particle at birth.
- Max: The minimum size of our particle at death.
- Increase: Adjust in units the increase scalable value of our particle during the transition.
- Wiggle: Create size variations while our particle is transformed.
- COLOR3: Adjust the colors that our particle gets during its life, we can adjust the following values:
- Start: The color with which our particle is born.
- Halfway: The color that the particle adopts in the middle of its transition.
- Ending: The color that the particle adopts before dying.
- ALPHA3: Adjust the transparency of our particle during the transition. The adjustable values are as follows:
- Start: Adjust with how much transparency our particle is born.
- Halfway: Adjust transparency to half the life of our particle.
- Ending: Adjust the transparency value in the final phase of our particle.
- SPEED: It is the speed with which our particle travels. The following values are adjustable:
- Min: The minimum speed with which our particle begins.
- Max: The maximum speed that our particle will reach.
- Increase: The increase in speed during the transition between the first two values.
- Wiggle: The value of the effect that alters the velocity of the particle.
- Direction: It is the direction in which our particle moves, we can modify the following values:
- Min: The direction with which our particle begins.
- Max: The maximum direction value that our particle may adopt.
- Increase: The increase in direction during the transition between the first two values.
- Wiggle: The value of the effect that alters the direction of the particle.
- GRAVITY: Adjust the gravity of our particle, the following values are adjustable:
- Amount: The amount of gravity assigned to our particle.
- Direction: The direction in which gravity affects our particle.
- ORIENTATION: It is the rotation that our particle adopts, the following values can be adjusted:
- Min: The minimum angle assigned at birth our particle.
- Max: The maximum assigned angle that our particle will inherit.
- Increase: The angle increase during its useful life until reaching its maximum value.
- Wiggle: The value of the effect that alters the rotational transition of our particle.
- Relative: Determine if the angle will be relative to the direction of transfer of our particle.
- BLEND: Determine if we want the assigned colors to be displayed additively, giving luminosity and prioritizing these colors over those of the texture:
- Aditive: Adjust this bool type value to create the mentioned effect.
- LIFE: Adjust the life of our particle, the values to be modified are as follows:
- Min: The minimum lifetime of our particle (measured in cpu steps, 60 represents 1 second).
- Max: The maximum lifetime that a particle can reach.
- PARTICLES: The number of particles to create in each frame.
- Num: Adjust the number of particles that will be born.
- ADD PART: Add new particles during the transition of others, the values to be modified are as follows:
- Step: With this value activated, we will create an extra particle (chosen by the user) in each frame.
- Death: With this value activated, we will create an extra particle (chosen by the user) when a particle dies.
- EMITTER: Create a region in our scenario where particles will be created randomly in that perimeter. The values to be modified are the following:
- Enabled: Decide if you want to activate a perimeter where our particles are generated.
- Shape: Determine default ways to generate particles in our emitter:
- Rectangle: The emitter generates particles forming a rectangle.
- Elipse: The emitter generates particles forming a circle.
- Diamond: The emitter generates particles forming a rhombus.
- Line: The emitter generates particles forming a straight line in the direction indicated with the mouse.
- Distribution: Adjust the distribution curve in which our particles are emitted, the values that we can adjust are the following:
- Linear: Our emitter distributes the particles evenly throughout a line perimeter.
- Gaussian: Our emitter distributes the particles towards the center of our region.
- InvGaussian: Our emitter distributes the particles to the edges of our perimeter.
- REGION: Adjust the perimeter of our issuer, the values that we can modify are the following:
- xMin: Determine the first point of our rectangle on the X axis from the upper left corner.
- xMax: Determine the second point of our rectangle on the X axis from the lower right corner.
- yMin: Determine the first point of our rectangle on the Y axis from the upper left corner.
- yMax: Determine the second point of our rectangle on the Y axis from the lower right corner.
1.4 – Configuring particles
How can we observe, we already have our particle system active. Now we just have to adjust their functions to create the desired effects.
In this case we will activate the emitter, which generates the particles from a rectangular perimeter and with a distribution that generates a greater quantity through the center of it.
1.5 – Adding particles to the system
We are allowed the option to chain particles when you die or in each frame if desired, in this case we want to create a new particle when it dies.
To do this we duplicate our system to take advantage of the data it contains.
We are interested in the data, but we are not interested in it being another particle system, we want the particle data that our duplicate houses to become part of the first object.
To achieve this we will remove the object assignment from our duplicate object. As we see in the image below, just write the name of an object that does not exist.
When an asset in our scenario has an object assigned, it will draw an icon informing that it contains logic. With the comments in the previous paragraph, we want that icon to disappear in our second particle.
Well, now we have a particle system that generates tree leaves (indicated by the cross in the image below). On the other hand we have data from a particle (indicated by the cursor in the image below).
Thanks to the system of relatives, we can configure countless particles that will be part of a single system. In this case, we assign as an object the object that only contains the data.
Now if we open our particle panel we can configure the data of our selected object, making our particle system (the father), generate new particles when others die.
This is achieved by changing the values located in the ADD PART function. We are interested in having the DEATH box activated, which is what warns our father that this particle is generated with the death of another. And so we do, we have changed the color of the new particle so that you can distinguish what happens.
What they witness is a particle that chains the creation of another particle. In this way, we can create two effects simulating that our first particle changes direction at a given time (which would be its death).
This technique allows us to have absolute control by being able to modify its behavior particle by particle. The possibilities are almost endless.
1.6 – Duplicating particle systems
A particle system can be duplicated, taking into account the number of family members that integrate it. In this way we assign a system for each tree in our game.
Remember that regardless of what our objects contain, these can be family of any object shown on the screen … Little by little we are ordering a hierarchy easy to control.
Now we only have to test the results during the game …
As we see in the image below, everything seems to work correctly. But if you look closely, the objects that house the particle data draw a sheet each.
These objects had the assignment of that image, but we are not interested in drawing them in the game since our particle system does that function.
For this we will select the objects that we do not want to be drawn on the screen. Then we will go to our INSPECTOR panel and change the VISIBLE INGAME variable to “false / 0”. With this our object will have the drawing event canceled.
And this is our final result, some trees that give off leaves as a result of temporary evil. A beautiful effect that gives our video game a lot of life and is very easy to implement.
1.7 – Scaling particle systems
DarkSpine is very powerful and dynamic. And when it comes to scale objects, apart from taking into account families, it also takes into account its content.
If we decide to scale the tree in the image below and it contains a child with a particle system, the hierarchy of the entire system will be scaled in a relative way. Thus we can create trees of different sizes without having to repeat processes. This provides us with an immense workflow.
This is the result of a scaled object that contained a particle system. We can appreciate that the leaves of the tree have automatically changed their size, adapting to the new scale of our tree.
This is another example of the power of our system of relatives, but here its benefits do not end, in future articles we will see more about this powerful system.
We strongly recommend that you view the video located at the beginning of this article to get a clear idea of this section.
The video tutorials provided on the YouTube channel support subtitle contributions from users. This means that any user can contribute to add subtitles with the editor and the new contribution program of YouTube subscribers.
So far we say goodbye for today, I hope you enjoyed this entry and that you get the most out of these tools.
For any questions you can comment below this article your opinions or questions.
I send you my best regards and see you in the next article!