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

Attaching a Particle Emitter to a Moving Object - Advice Needed

Chris Smith

Member
Greetings game makers!

At the moment I am working on an intro cut scene for a game I'm working on and it involved a rocket flying in many directions across the screen. I created a fire for the rear of the rocket, by using a particle emitter. Both the rocket and the fire, here, will only be used for the intro sequence, so I put the particle emitter in the rocket object, and it works great, except I don't know how to get the fire to stay in its place on the rear of the rocket. I'm quite new to GML still, so I'm struggling to figure out exactly how to do this.
For testing I just created a room and put control code on the rocket to move it around. I've attached a short video that will show better than I can explain.


This is the code being used:

obj_introship CREATE
//Particle System​
partfire_system = part_system_create();

//Fire Particles
partfire = part_type_create();
part_type_sprite(partfire,spr_shipfire,0,0,1)
part_type_size(partfire,1,2,0,0);
part_type_colour3(partfire,c_yellow,c_orange,c_red);
part_type_alpha3(partfire,1,1,0);
part_type_speed(partfire,4,20,0,0);
part_type_direction(partfire,85,95,0,10)
part_type_orientation(partfire,0,359,0,0,0);
part_type_blend(partfire,1);
part_type_life(partfire,8,20);

//Particle Emitter
partfire_emitter = part_emitter_create(partfire_system);
part_emitter_region(partfire_system,partfire_emitter,x-100,x+100,y-20,y+20,ps_shape_ellipse,ps_distr_linear);​


obj_introship STEP

///FIRE
part_emitter_burst(partfire_system,partfire_emitter,partfire,10)
part_emitter_region(partfire_system,partfire_emitter,x-160,x-96,y-32,y+32,ps_shape_ellipse,ps_distr_linear);

part_type_size(partfire,.7,1.3,0,0);
part_type_direction(partfire,(image_angle-20)+180,(image_angle+20)+180,0,10)
part_type_orientation(partfire,0,359,0,0,1);​


Thanks for your time!
 
  • Wow
Reactions: Mut

johnwo

Member
Set the [x1/y1/x2/y2] of part_emitter_region by using [x/y]+lengthdir_[x/y] to compensate for the rotation.
 

Chris Smith

Member
Set the [x1/y1/x2/y2] of part_emitter_region by using [x/y]+lengthdir_[x/y] to compensate for the rotation.
You mean the xmin/xmax/ymin/ymax?
What I have is this now:

part_emitter_region(partfire_system,partfire_emitter,lengthdir_x(-160, image_angle),lengthdir_x(-96, image_angle),lengthdir_y(-32,image_angle),lengthdir_y(32, image_angle),ps_shape_ellipse,ps_distr_linear);​

and it looks like the fire just disappears after a few steps. It did look like it was in the correct location for the few frames that it was there.
I'm having trouble comprehending the way lengthdir_ works in these arguments.
 

Chris Smith

Member
So the first argument in lengthdir_x/y is supposed to be the distance from the origin of the ship, to the x/y coordinate that I want to apply the region limits to?

I've adjusted the numbers to reflect that. And now the fire is off in the top left corner of the room, it turns with my image angle, but it does not move.

part_emitter_region(partfire_system,partfire_emitter,lengthdir_x(-100, image_angle-180),lengthdir_x(-128, image_angle-180),lengthdir_y(-32,image_angle-180),lengthdir_y(32, image_angle-180),ps_shape_ellipse,ps_distr_linear);
 
J

Jaqueta

Guest
Use the lenghtdir+the spaceship position, like this:
x+lenghtdir_x(.....)
 

Chris Smith

Member
Use the lenghtdir+the spaceship position, like this:
x+lenghtdir_x(.....)
Okay that makes sense.

Now I have this:
part_emitter_region(partfire_system,partfire_emitter,x+lengthdir_x(128, image_angle-180),x+lengthdir_x(128, image_angle-180),y+lengthdir_y(-32,image_angle-180),y+lengthdir_y(32, image_angle-180),ps_shape_ellipse,ps_distr_linear);

The rocket moves, and the fire moves with it, however I'm still having essentially the same problem that you can see in the video. its not quite the same, but the fire lines up perfectly when i'm facing right or left, but when i'm facing up or down, the fire finds itself in the middle of the rocket.
 
J

Jaqueta

Guest
Instead of using -32 and 32 on the lenghtdir y, use 128 as well; its kinda hard to understand what lenghtdir does at first, i had the same problem xD, this might help you.

and also this:
 
Top