Nuclear Detergent
Member
Large particle systems can use a lot of system resources, and easily course memory leaks.
I'm trying to build a rain particle system, trying to build something efficient. My idea is to use part_emitter_region to update the position of the instance creating the rain, with coordinates based on the camera. This seems to be possible as the documentation eludes to it. However, I can't get this approach to work.
Here's the code
The particle system is stationary in the above example. I've tried multiple x- and y-inputs, but it remains stationary. Perhaps the idea of moving the emitter is outside the scope of what the intention in GM2 is?
Is there some sort of best practice, or better examples of how to large systems, that wont spand the entire room, but only whats inside the view?
I'm trying to build a rain particle system, trying to build something efficient. My idea is to use part_emitter_region to update the position of the instance creating the rain, with coordinates based on the camera. This seems to be possible as the documentation eludes to it. However, I can't get this approach to work.
Here's the code
Code:
Create event
xmin = 0;
xmax = 0;
ymin = 0;
ymax = 0;
//Rain System
partRain_sys = part_system_create();
//Rain Particle
partRain = part_type_create();
part_type_shape(partRain,pt_shape_line);
part_type_size(partRain, 0.1, 0.1, 0, 0);
part_type_color2(partRain, c_blue, c_white);
part_type_alpha2(partRain, 0.25, 0.75);
part_type_gravity(partRain, 0.1, 290);
part_type_speed(partRain, 0.5, 0.5, 0, 0);
part_type_direction(partRain, 250, 330,0,1);
part_type_orientation(partRain,290, 290, 0, 0, 0);
part_type_life(partRain,room_speed,room_speed*2.2);
gpu_set_blendmode(bm_add);
//Create Emitter
partRain_emit = part_emitter_create(partRain_sys);
part_emitter_stream(partRain_sys,partRain_emit,partRain,5);
//Advance System
repeat (room_speed * 5) {
part_system_update(partRain_sys);
}
Code:
Step event
xmin = camera_get_view_x(view_camera[0]);
xmax = camera_get_view_x(view_camera[0]) + 400;
ymin = camera_get_view_y(view_camera[0]);
ymax = camera_get_view_y(view_camera[0]) + 400;
//Update Emitter
part_emitter_region(partRain_sys,partRain_emit, xmin, xmax, ymin, ymax, ps_shape_line, ps_distr_linear);
part_particles_clear(partRain);
Is there some sort of best practice, or better examples of how to large systems, that wont spand the entire room, but only whats inside the view?
Last edited: