1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Particles issue [SOLVED]

Discussion in 'Programming' started by junk-boy, Sep 10, 2019.

  1. junk-boy

    junk-boy Member

    Joined:
    Sep 10, 2019
    Posts:
    6
    So, I am pretty new with Game Maker, and I have been struggling with particle system recently. I did some bunch of code, and it seems to be working, but, for some reason, there are some issues with particles - first, they are not drawn on any light colors and second, they are being overlapped by the objects. As English is not my native language, and so mistakes can be here and there, you can just look at the gif I attached below to (hopefully) understand what I am talking about.
    EDIT: Here's the code, I totally forgot about that
    EDIT2: Attached some more gifs to show what I got
    Code:
    RainParticle = part_system_create();
    
    rain_particle = part_type_create();
    part_type_shape(rain_particle,pt_shape_line);
    part_type_size(rain_particle,0.10,0.10,0,0);
    part_type_scale(rain_particle,1,1);
    part_type_color1(rain_particle,c_red);
    part_type_alpha1(rain_particle,1);
    part_type_speed(rain_particle,6,6.5,0,0);
    part_type_direction(rain_particle,290,293,0,0);
    part_type_gravity(rain_particle,0,270);
    part_type_orientation(rain_particle,0,0,0,0,1);
    part_type_blend(rain_particle,1);
    part_type_life(rain_particle,60,62);
    //part_type_color_mix(rain_particle,c_gray, c_dkgray);
    
    rain_emitter = part_emitter_create(RainParticle);
    part_emitter_region(RainParticle,rain_emitter,-640,room_width,-120,y,ps_shape_line,ps_distr_linear);
    part_emitter_stream(RainParticle,rain_emitter,rain_particle,3);
    
    repeat (room_speed * 3)
       {
        part_system_update(RainParticle);
       }
     

    Attached Files:

    • al0.gif
      al0.gif
      File size:
      174.1 KB
      Views:
      5
    • al1.gif
      al1.gif
      File size:
      278.4 KB
      Views:
      5
    • al2.gif
      al2.gif
      File size:
      257.6 KB
      Views:
      5
    Last edited: Sep 11, 2019
  2. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    997
    When you create the particle system, you need to create it on a layer that is above those objects.
     
  3. junk-boy

    junk-boy Member

    Joined:
    Sep 10, 2019
    Posts:
    6
    I think I did that? I mean, the object that creates those particles is on the topmost layer of the room
     
  4. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    997
    Are you creating a particle system using part_system_create_layer() ?

    You are giving us no code, so I have to guess what you're doing.

    Particles can be created by objects that are on any layer, but the particle will spawn on the layer set by part_system_create_layer().
     
  5. junk-boy

    junk-boy Member

    Joined:
    Sep 10, 2019
    Posts:
    6
    Oops, my mistake. Here's the code I have.
    Code:
    RainParticle = part_system_create();
    
    rain_particle = part_type_create();
    part_type_shape(rain_particle,pt_shape_line);
    part_type_size(rain_particle,0.10,0.10,0,0);
    part_type_scale(rain_particle,1,1);
    part_type_color1(rain_particle,c_red);
    part_type_alpha1(rain_particle,1);
    part_type_speed(rain_particle,6,6.5,0,0);
    part_type_direction(rain_particle,290,293,0,0);
    part_type_gravity(rain_particle,0,270);
    part_type_orientation(rain_particle,0,0,0,0,1);
    part_type_blend(rain_particle,1);
    part_type_life(rain_particle,60,62);
    //part_type_color_mix(rain_particle,c_gray, c_dkgray);
    
    rain_emitter = part_emitter_create(RainParticle);
    part_emitter_region(RainParticle,rain_emitter,-640,room_width,-120,y,ps_shape_line,ps_distr_linear);
    part_emitter_stream(RainParticle,rain_emitter,rain_particle,3);
    
    repeat (room_speed * 3)
       {
        part_system_update(RainParticle);
       }
    EDIT: I tried changing part_system_create() to part_system_create_layer(), and nothing changed
     
  6. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    997
    So you tried using part_system_create_layer() to create the system on a layer above all the object layers? Note, the layer needs to be passed as a string.
     
  7. junk-boy

    junk-boy Member

    Joined:
    Sep 10, 2019
    Posts:
    6
    Yes, I tried that, and nothing have changed
     
  8. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    184
    Try adding:

    Code:
    part_system_depth ();
    Somewhere in there, I put near the top. It requires two arguments if I remember correctly, the second value being the depth i.e.- part_type_depth(*particle name*, -10000); (remove the asterisks).

    Onnie
     
  9. junk-boy

    junk-boy Member

    Joined:
    Sep 10, 2019
    Posts:
    6
    Adding that doesn't work, too

    I attached some more gifs to show what I mentioned about that light color thing. Looking at the result, it seems that particles change their transparency depending on the brightness or something of the color, as they are being drawn on black color with transparency of 1, while being drawn on white with transparency of 0. I really have no idea what's going on, I have nothing else about the particle system exept that piece of code in a create event
     

    Attached Files:

    • al0.gif
      al0.gif
      File size:
      174.1 KB
      Views:
      5
    • al1.gif
      al1.gif
      File size:
      278.4 KB
      Views:
      5
    • al2.gif
      al2.gif
      File size:
      257.6 KB
      Views:
      5
  10. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    997
    You are setting the blending here:
    Code:
    part_type_blend(rain_particle,1);
    
    So you will need to set it to 0 if you don't want it to blend.
     
  11. junk-boy

    junk-boy Member

    Joined:
    Sep 10, 2019
    Posts:
    6
    YES, that's exactly what I needed! And jeez, I feel really stupid now, I didn't even notice that:oops:
    Anyways, thanks for all the help!
     
    OnLashoc likes this.
  12. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    184
    My answer was in regards to depth. I have that this line of code in my particle system coding on the step event, I might have said create event.

    Code:
    part_system_depth(particle1,400 );
    And now it is correctly drawing under the object I needed it to.

    Onnie
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice