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

GameMaker Moving particle effect with camera

Hi all. I'm using Gamemaker Studio 2. Creating an atmospheric fog using particle system. The problem is that the effect stays anchored in the 0,0 coordinate of the room rather than moving with the camera. I've implemented code that is intended to address this, but it isn't working. (Oddly, I have another particle system in game for rain that follows the camera properly, and it uses practically identical code to the fog system.)

Here's the create event for the fog system:

Code:
width = camera_get_view_width(0);
height = camera_get_view_height(0);
xx = view_get_xport(0);
yy = view_get_yport(0);
stream_rate = -13;

part_fog_system = part_system_create();
part_system_depth(part_fog_system,-4000);

//fog paricle
part_fog = part_type_create();
part_type_shape(part_fog,pt_shape_cloud);
part_type_size(part_fog,3,5,0,0);
part_type_color2(part_fog,c_maroon,c_fuchsia);
part_type_alpha3(part_fog,0.3,0.35,0.4);
part_type_speed(part_fog,0.7,1,0,0);
part_type_direction(part_fog,330,359,0,0);
part_type_life(part_fog,500,700);

// create particle emitter
part_fog_emit = part_emitter_create(part_fog_system);
part_emitter_region(part_fog_system,part_fog_emit,xx-80,xx,yy-32,yy+280,ps_shape_ellipse,ps_distr_gaussian);
part_emitter_stream(part_fog_system, part_fog_emit, part_fog, stream_rate);

//Advance system
repeat(room_speed*10)
    {
    part_system_update(part_fog_system);
    }
There's also this room_start code (mainly used when returning from "pause room"):
Code:
part_system_automatic_update(part_fog_system,true);
part_emitter_region(part_fog_system,part_fog_emit,xx-80,xx,yy-32,yy+280,ps_shape_ellipse,ps_distr_gaussian);
part_emitter_stream(part_fog_system, part_fog_emit,part_fog,stream_rate);
repeat(room_speed*10)
    {
    part_system_update(part_fog_system);
    }
Then, in the step event:
Code:
part_emitter_region(part_fog_system,part_fog_emit,xx-80,xx,yy-32,yy+280,ps_shape_ellipse,ps_distr_gaussian);
part_emitter_stream(part_fog_system, part_fog_emit,part_fog, stream_rate);
I'm considering implementing a temporary fix in which the fog covers the width and height of the room, rather than just the view, but I know this is less than ideal from a performance standpoint. Any suggestions as to how to get the fog to properly follow the view?
Thanks!
 
A

Anomaly

Guest
Try making your region 2nd x dimension be room_width+100 ?
 
Top