Particle part_type_life seems broken, it never stops emitting.

J

Jack_cipher

Guest
here is my code, as far as I can tell the particle should live for 20 to 25 seconds and die off, but it doesn't. please help.

GML:
firstParticleSystem = part_system_create();
part_system_depth(firstParticleSystem,0);


grey = make_colour_rgb(93, 89, 89);

dust = part_type_create();
part_type_shape(dust,pt_shape_cloud);
part_type_life(dust,20,25);
part_type_scale(dust,1,1);
part_type_size(dust,1,1.5,-.001,0);
part_type_color1(dust,grey);
part_type_alpha2(dust,1,0.75);
part_type_speed(dust,0.1,0.5,0,0);
part_type_direction(dust,0,359,0,0);
part_type_gravity(dust,0.001,90);
part_type_orientation(dust,0,359,60,0,true);
part_type_blend(dust,true);

dust_emitter = part_emitter_create(firstParticleSystem);
part_emitter_region(firstParticleSystem,dust_emitter,x-20, x+20, y-20, y+20, ps_shape_ellipse, ps_distr_gaussian);
part_emitter_stream(firstParticleSystem,dust_emitter,dust,1)
 

TsukaYuriko

☄️
Forum Staff
Moderator
part_type_life does not take units of seconds, but of frames. It also has nothing to do with particles being emitted. That's part_emitter_stream's doing. Check its manual page to find out how to stop streaming particles.

If this is supposed to be a one-off type of effect that spawns particles just once (rather than continuously over the course of many frames), you may be looking for part_emitter_burst or part_particles_create, the latter of which doesn't rely on emitters at all and thus no emitter needs to be stopped (or created).
 
J

Jack_cipher

Guest
part_type_life does not take units of seconds, but of frames. It also has nothing to do with particles being emitted. That's part_emitter_stream's doing. Check its manual page to find out how to stop streaming particles.

If this is supposed to be a one-off type of effect that spawns particles just once (rather than continuously over the course of many frames), you may be looking for part_emitter_burst or part_particles_create, the latter of which doesn't rely on emitters at all and thus no emitter needs to be stopped (or created).
Thank you, changing it to part_emitter_burst worked for me.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Just to make sure, you are destroying the particle system, type and emitter after you're no longer using them, right? You didn't show that part of the code. If you're not doing that, you have a memory leak. Not a very big one, but depending on how many of these dust clouds you're spawning, it can add up. You can technically keep the system and type alive for the entire game if you're commonly spawning dust, but the emitter seems pretty useless to me after being used once since this seems like a one-off particle spawn.
 
Top