Legacy GM [SOLVED] Specific Instance Burst Emitter Checking

Wuzzems

Member
I currently have my particle system,type,emitter etc setup within a script (Particle_1) which I call upon when obj_small is in the vicinity of obj_ship and the player has pressed space.

All of the obj_small instances are moving to the left

Code:
if !place_empty(x,y) && keyboard_check_pressed(vk_space)

    {
    script_execute(Particle_1);
    instance_destroy();
    }
I should also mention that I have this code running in the step event of the obj_small object

All of this works fine. My problem occurs when the player, in this case the obj_ship, misses one of these obj_small objects but gets the next one. When the player gets the next one, the particle effect then happens at the already passed obj_small object instead of the one currently having the action done to it.

I have code that takes care of the ones that are already off of the screen which helps but if it's still on screen for even a split second then that particle effect will take place at that one.

My question is how can I get my particle effect to only take place at the one having the action done to it? (the instances that the player presses space on).

The only thing I can think of is to send the instance ID of the instance having the action done to it to the script's part_emitter_region although I have no idea how to do implement this. I currently just have the region set to obj_small.x,y etc

Script's code:

Code:
//particle system

part1_sys = part_system_create();
part_system_depth(part1_sys, 20);

//particle

part1 = part_type_create();
part_type_shape(part1, pt_shape_ring);
part_type_scale(part1, 1, 1);
part_type_size(part1, 2, 5, 0.5,0.7);
part_type_speed(part1, 2, 3, -0.02, -0.5);
part_type_direction(part1, 0, 359, 1, 3);
part_type_blend(part1, 1);
part_type_colour1(part1, c_blue);
part_type_life(part1, room_speed, room_speed * 2);
part_type_alpha2(part1, 1, 0);

//particle emitter

part1_emit = part_emitter_create(part1_sys);
part_emitter_region(part1_sys, part1_emit, obj_small.x-5, obj_small.x+5, obj_small.y-5, obj_small.y+5, ps_shape_ellipse, ps_distr_gaussian);
part_emitter_burst(part1_sys, part1_emit, part1, 5 + irandom(4) );
Something else that also seems to happen is that the instances of obj_small are at different Y positions and when I hit one of the instances that are at a higher y position with spacebar when it's in reach then the particle effect seems to occur in the middle of the room or at least the middle of the Y axis near the other instances that are in the center of the y axis.

If there is an easier way of doing all of this, please mention it, I would very much appreciate any help on this topic. If any other information is required then I will add it as it's brought up.
 
Q

Quackertree

Guest
The code of your script already runs in obj_small.

Code:
part_emitter_region(part1_sys, part1_emit, obj_small.x-5, obj_small.x+5, obj_small.y-5, obj_small.y+5, ps_shape_ellipse, ps_distr_gaussian);
This bit of code will reference obj_small again, even though it is already in it. This means that the last created obj_small will return it's coords, as this is the first obj_small which will return that it exists. You should ditch the obj_small. here in order to solve your problem.

P.S.: Note, that you never destroy your particle system / part / emitter. Eventually you're going to overflow in memory, because you keep creating new ones. I suggest creating just one particle system / part / emitter as global variables and referencing them through your script. This way, you'll just work with on system, instead of infinitely many. :)
 
Top