• 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!

Particle effect not working

M

Misu

Guest
Im using GMS2 and I cant get my particle effects to work (they dont show up). Can anyone tell what might be the problem with my coding?

CREATE EVENT:
Code:
ss = surface_create(1280,960)

stream = part_system_create()
part_system_depth(stream,1000)

p_type = part_type_create()
part_type_sprite(stream,spr_part,0,0,1)
part_type_size(stream,0.01,2,0.01,0)
part_type_alpha2(stream,0,1)
part_type_color2(stream,c_white,c_white)

part_type_direction(stream,0,360,0,0)
part_type_speed(stream,16,32,0,0)
part_type_life(stream,100,200)
DRAW GUI EVENT
Code:
surface_set_target(ss)
draw_clear_alpha(0,0)

 part_particles_create(stream,320,240,p_type,2)

surface_reset_target()

draw_surface_stretched(ss,0,0,640,480)
 

jo-thijs

Member
Im using GMS2 and I cant get my particle effects to work (they dont show up). Can anyone tell what might be the problem with my coding?

CREATE EVENT:
Code:
ss = surface_create(1280,960)

stream = part_system_create()
part_system_depth(stream,1000)

p_type = part_type_create()
part_type_sprite(stream,spr_part,0,0,1)
part_type_size(stream,0.01,2,0.01,0)
part_type_alpha2(stream,0,1)
part_type_color2(stream,c_white,c_white)

part_type_direction(stream,0,360,0,0)
part_type_speed(stream,16,32,0,0)
part_type_life(stream,100,200)
DRAW GUI EVENT
Code:
surface_set_target(ss)
draw_clear_alpha(0,0)

 part_particles_create(stream,320,240,p_type,2)

surface_reset_target()

draw_surface_stretched(ss,0,0,640,480)
Well, you never told the particles to get drawn, so it's no suprise they're not getting drawn.
Also, you really should not be creating new particles inside a draw event.
You should either set particles to be automatically generated or create them in a step event or something like that.

This code for example, does work:
Create event:
Code:
ss = surface_create(1280,960)

stream = part_system_create()
part_system_depth(stream,1000)

p_type = part_type_create()
part_type_sprite(stream,sprite_0,0,0,1)
part_type_size(stream,0.01,2,0.01,0)
part_type_alpha2(stream,0,1)
part_type_color2(stream,c_white,c_white)

part_type_direction(stream,0,360,0,0)
part_type_speed(stream,16,32,0,0)
part_type_life(stream,100,200)

part_system_automatic_draw(stream,false);
Step event:
Code:
part_particles_create(stream,320,240,p_type,2)
Draw GUI event:
Code:
surface_set_target(ss)
draw_clear_alpha(0,0)

part_system_drawit(stream)

surface_reset_target()

draw_surface_stretched(ss,0,0,640,480)
 
E

Ethan Stark

Guest
In my script I use next code, initialization:
Code (CSharp):
_collisionParticles = transform.parent.FindChild("PlayerCollisionParticles").GetComponent<ParticleSystem>();
To play I use this code:
Code (CSharp):
_collisionParticles.Play();
And to stop:
Code (CSharp):
_collisionParticles.Stop();
Also, while I log _collisionParticles.isPlaying before and after I notice, after Play() it logs true, but after Stop() it remains true - and in both states I don't see any emission.

Ethan Stark
 
Top