• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Multiple objects using same particle system

C

Crossoni

Guest
I'm trying to use same particle system on multiple objects with different part_type settings, but for some reason the objects use the same settings when using part_particles_create. What I noticed is that draw event and particles work differently on this area:
Code:
///Draw event
draw_set_color(c_white);
draw_text(x,y,"text"); // Draws white text

draw_set_color(c_red);
draw_text(x,y,"text"); // Draws red text
Code:
///Creating particles
part_type_colour1(global.p_jetpack,c_white);
part_particles_create(global.p_sys_jetpack,x,y,global.p_jetpack,1); // Creates red particle

part_type_colour1(global.p_jetpack,c_red);
part_particles_create(global.p_sys_jetpack,x,y,global.p_jetpack,1); // Creates red particle
Particles seems to go through the whole code and then it chooses the last settings given to particle type and system.

Is there a way to use the same particle system and type with multiple objects using different type settings or do I have to use arrays for my particle types? I hope that arrays are not the only solution since it will complicate many things in my code. Here is my code now:

Code:
///Initialize particle systems and types when game launches
global.p_sys_jetpack = part_system_create();
global.p_jetpack = part_type_create();

///Create particles on objects
part_type_blend(global.p_sys_jetpack,true);
part_type_alpha2(global.p_jetpack,1,0.2)
part_type_colour2(global.p_jetpack,colors[jetpackinpos],colors[jetpackoutpos]);
// etc.
part_particles_create(global.p_sys_jetpack,x,y,global.p_jetpack,1);
For choosing to use global variables for particles I followed this guide: https://www.yoyogames.com/blog/50/quick-start-to-programming-particles Before this I created the particle system and type separately on every object and destroyed it when the object got destroyed, but it slowed down my game significantly.
 

Simon Gust

Member
When you create a part type, all options you change on it will affect every particle (even if it already has started) of that type.
If you want individual particles, you have to create a type for each particle.

Creating a particle type will consume memory, so it's important that you free that memory by deleting the particle type when it's no longer used.

You should however only have 1 particle system for your setup.
 
Quick question @Simon Gust, what's the reasoning for only one particle system? I've had a system for years now where I create an object for a particle effect that I want (let's say obj_fireball_particles), within that object I handle the particle system as a completely closed system. The object creates a local particle system and any emitters I want and the particle types, then when I'm done with the effect (let's say the fireball hits a wall), I can control exactly when the particles will disappear (deleting the fireball object won't delete the particles for it necessarily, so I can have it stream for a little longer if I want) and when I'm totally done with that instance of the effect, I just delete the obj_fireball_particles instance and within it's destroy/clean up event I'll destroy the particle system, any emitters and any particles. This has never been enough overhead for me to run into any speed problems when using it, but I am curious if there could possibly be some downsides to creating multiple particle systems (besides the speed issue I just mentioned)?
 

Simon Gust

Member
Quick question @Simon Gust, what's the reasoning for only one particle system? I've had a system for years now where I create an object for a particle effect that I want (let's say obj_fireball_particles), within that object I handle the particle system as a completely closed system. The object creates a local particle system and any emitters I want and the particle types, then when I'm done with the effect (let's say the fireball hits a wall), I can control exactly when the particles will disappear (deleting the fireball object won't delete the particles for it necessarily, so I can have it stream for a little longer if I want) and when I'm totally done with that instance of the effect, I just delete the obj_fireball_particles instance and within it's destroy/clean up event I'll destroy the particle system, any emitters and any particles. This has never been enough overhead for me to run into any speed problems when using it, but I am curious if there could possibly be some downsides to creating multiple particle systems (besides the speed issue I just mentioned)?
I only meant in this scenario where you just want individual particles, you have to make part types for each but not part systems.

Other than that, you should always look at the options you have avaliable for your particles. You see that you can change the most in a particle type but a particle system can only change depth and base position.
If you never change these options, why make another system that is the exact same as your first system.
 
C

Crossoni

Guest
When you create a part type, all options you change on it will affect every particle (even if it already has started) of that type.
If you want individual particles, you have to create a type for each particle.

Creating a particle type will consume memory, so it's important that you free that memory by deleting the particle type when it's no longer used.

You should however only have 1 particle system for your setup.
I found out that the reason why the game got slowed down was that I accidentally created partition type and system every step on my objects, not only when it got created. I don't know how I missed that, but my system is now working properly. Thanks for the help and for answering my questions.
 
I only meant in this scenario where you just want individual particles, you have to make part types for each but not part systems.

Other than that, you should always look at the options you have avaliable for your particles. You see that you can change the most in a particle type but a particle system can only change depth and base position.
If you never change these options, why make another system that is the exact same as your first system.
Yeah, I've thought about the 'why create the same system again' question before. But my reasoning has been (mostly due to laziness) that having to juggle a few systems manually is more intellectually demanding than having an 'automated' system handle it, so it's worth it for my 'coding flow'. I misunderstood your original statement I think, I took it the same as what people mean when they say "Don't use the Solid option" i.e. it's -there- but it's going to introduce real bugs into your system that you don't need. So I assumed using more than one particle system might have annoying 'quirks' around it like Solid does. But now I think you meant it more as a general guide about having no need to introduce two systems when one will do the job fine.
 
Top