How to advance built-in rain effect

J

justinhook

Guest
I'm creating rain using the built in ef_rain:

Code:
effect_create_above(ef_rain, 0, 0, 1, c_gray);
And when I run it, the rain starts. But I want it so that when the character enters the room, it looks like it's already been raining.

There's a command (part_system_update) for custom particle systems, but I can't get it to work for ef_rain.

I've also tried making the layer invisible or setting it's x value to off screen till use, but neither work.

Any ideas?
 
M

MilesTr11

Guest
I'm pretty new to Gamemaker so I'm not extremely knowledgeable when it comes to particles - A janky fix that I might consider depending on the details of your situation would be fading to black in-between rooms. This would at least give the rain a chance to start before it's entirely visible.
 
J

justinhook

Guest
Well I need this to be instant. But regardless, it doesn't seem to load when invisible anyway.
 

Bingdom

Googledom
You can create individual particles with the function part_particles_create(). With this, you can scatter it across the screen.
You will, however, will need to use the proper particle system to be able to use that function.

The function you mentioned requires an index to a particle system.
ef_rain is a constant and doesn't point to its particle system.
 

Dr. Wolf

Member
The basic idea of using part_system_update can work; you just have to repeat it a bunch so that the raindrops can make their way down the screen, like so:
Code:
if !part_particles_count(true) repeat 120
{
    part_system_update(true);
    effect_create_above(ef_rain, -1, -1, 1, c_gray);
};
You'd put this in your step event; you could also put it in an object's create event, without the conditional (you'll also want to change that if you're using effect_create_above to create some other particles first). Remember, effect_create_below works with particle system 0 (false), and effect_create_above works with particle system 1 (true).

Note also that you may find this only looks right if your game is set to 30fps (the default), not 60 or another value, because built-in particle effects hate life. Also, you'll wind up with much nicer rain if you just handle the particles yourself, rather than relying on the pre-made effects.
 
J

justinhook

Guest
The basic idea of using part_system_update can work; you just have to repeat it a bunch so that the raindrops can make their way down the screen, like so:
Code:
if !part_particles_count(true) repeat 120
{
    part_system_update(true);
    effect_create_above(ef_rain, -1, -1, 1, c_gray);
};
You'd put this in your step event; you could also put it in an object's create event, without the conditional (you'll also want to change that if you're using effect_create_above to create some other particles first). Remember, effect_create_below works with particle system 0 (false), and effect_create_above works with particle system 1 (true).

Note also that you may find this only looks right if your game is set to 30fps (the default), not 60 or another value, because built-in particle effects hate life. Also, you'll wind up with much nicer rain if you just handle the particles yourself, rather than relying on the pre-made effects.
I know to repeat part_system_update, but it's not having any effect. This code didn't work for me except to create 120 (way too many) rain events.

I will, I suppose, just make my own, but the truth is I like the built in one and it would work fine if I could get it to start 5 seconds into the animation.
 

CMAllen

Member
According the GM's own documentation, that's how you're supposed to do what you want to do -- part_system_update()
From the manual:
Code:
repeat (room_speed * 3)

   {
   part_system_update(global.RainSys);
   }
That should advance the particle sim 3 seconds. Are you saying that you're using identical code and nothing is happening?
 
J

justinhook

Guest
According the GM's own documentation, that's how you're supposed to do what you want to do -- part_system_update()
From the manual:
Code:
repeat (room_speed * 3)

   {
   part_system_update(global.RainSys);
   }
That should advance the particle sim 3 seconds. Are you saying that you're using identical code and nothing is happening?
I take it that global.RainSys is just an example. It doesn't seem to have an effect on an ef_rain system.

For anyone curious, here's the rain effect I created, which is fairly close to the stock version. Please feel free to point out logical errors, as I'm fairly new to particle systems.

Code:
Rain = part_system_create();
part_system_depth(Rain,0);
part_system_position(Rain, 0, 0);

raindrop = part_type_create();
part_type_shape(raindrop,pt_shape_line);
part_type_scale(raindrop,.7,.7);
part_type_size(raindrop,0.6,0.6,0,0);
part_type_color2(raindrop,c_gray,c_gray);
part_type_alpha2(raindrop,0.4,0.4);
part_type_speed(raindrop,09,09,0,0);
part_type_direction(raindrop,260,260,0,0);
part_type_gravity(raindrop,0,260);
part_type_orientation(raindrop,-10,-10,0,0,true);
part_type_life(raindrop,200,200);
part_type_blend(raindrop,false);


rain_emitter = part_emitter_create(raindrop);
part_emitter_region(Rain, rain_emitter, -100, room_width+100, 0, 0, ps_shape_line, ps_distr_linear);

part_emitter_stream(Rain,rain_emitter,raindrop,30);
repeat (room_speed * 6) {
part_system_update(Rain)
}
 
Top