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

Particle Spawn on Object

K

KevDoesArt

Guest
Ok I have a particle system set up to produce leaves out of a tree. All the code is set up correctly and I have it so that the tree spawns the obj for the particle system on creation but I cannot get the emitter to be on the tree. I set the create code for the obj to x = obj_tree.x and the same for y but still nothing. I think it has something to do with the emitter_region section but I cannot figure it out.
 
K

KevDoesArt

Guest
I changed the x value to room width to see if that would help but did not...
emitter.jpg
 
F

fxokz

Guest
Code:
part_emitter_region(global.p1, am, (obj_tree01.x)-20, (obj_tree01.x)+20, (obj_tree01.y)-20, (obj_tree01.y)+20, ps_shape_rectangle, ps_distr_linear);
The region is where you set the x and y coordinates. Give my code a try and tell me what happens.

(Took me 10 years to write that down on my phone xd)
 
K

KevDoesArt

Guest
Gave this error. Your code looked solid though. The code itself had no typo errors (the line number didn't turn red)
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_leafP_emit:

global variable <unknown built-in variable>(-1610512732, -2147483648) not set before reading it.
at gml_Object_obj_leafP_emit_CreateEvent_1 (line 9) - part_emitter_region(global.p1, am, (obj_tree01.x)-20, (obj_tree01.x)+20, (obj_tree01.y)-20, (obj_tree01.y)+20, ps_shape_rectangle, ps_distr_linear);
############################################################################################
 
F

fxokz

Guest
Im not exactly sure what the reason for the error is but the way you set up the particles seems weird. If i were you i would have just created the particle system in the tree object instead of making it a seperate object.

You should remove the first 2 lines of code if you have multiple trees in the room.

Edit: remove it regardless its useless.
 
K

KevDoesArt

Guest
Yeah setting it up in the tree object might be better. It was kind of an after thought while making another system.
 
K

KevDoesArt

Guest
I see what the error was - you put global.p1 instead of pl
 
F

fxokz

Guest
Is the object in the room?

edit: man i would just copy all of the code from the leaf object and paste it into the tree. The way you are doing it doesnt seem efficient
 
Last edited:
K

KevDoesArt

Guest
It's all in the tree and it is in the room. I could take out the step event I guess. I am using sort of a state machine for the code because I have multiple particle systems and it just makes it easier to duplicate them then copy and paste.
 
Top