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

How does particles?

Drell

Member
I'm usually pretty good with reading the manual and figuring things out, but I think I'm misunderstanding something fundamentally about how particles work. I'm currently using particles for on hit effects in my game which is working brilliantly. However I'm trying to do the same thing for the jumpDust, and it isn't creating the particles in the right place. I've got the following code (which again is working perfectly fine for the onhit effects) that is creating the particles, but doing so in 0,0 position in the room.

Code:
var source = self.id;   
with (partBlood){
[INDENT]part_emitter_region(colDust,jumpDust,source.x,source.x+12*sign(image_xscale),source.y,source.y,ps_shape_ellipse,ps_distr_gaussian);[/INDENT]
            part_emitter_burst(colDust,dust,jumpDust,20);
            }
A solution to the problem would be great, but I'd really like to understand the problem so I can solve any new issues that arise.


An example of the already working on hit effects

 
P

ParodyKnaveBob

Guest
Howdy, Drell. Neat looking effects and artwork you have going on there already. $:^ ] Also, glad you hit the manual and try things -- I hope others learn from that...

First, quick little thing, you don't need self.id to get the id -- just id by itself will work (and in nearly every case, self is pretty useless fwiw).

Second, your actual issue.
  • What object is calling this code, and from what event? It kind of sounds like a controller (at x,y = 0,0 not accounting for +12*sign(image_xscale)) so far...
  • If that didn't solve it already, then what's your working code for side-by-side comparison?
  • And btw, (also if not solved already,) showing 0,0 in room (for which you'd likely need some good debugging to see) or 0,0 in the view?
Regards,
Bob $:^ J
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Have you read this article I wrote a while back? Still relevant and a great place to start... http://www.yoyogames.com/blog/50

Other than that a few comments... first, there is almost never any reason to use "self". It's pretty much deprecated so stop using it and simply assign the "id" variable to the local variable. Second, are you sure you need an emitter? Maybe you should forget that and look at just using part_particles_create? In most simple cases an emitter isn't required and just bursting the particles with that function is fine (you can even do it over an area using repeat and a random set of positions).
 

Drell

Member
Howdy, Drell. Neat looking effects and artwork you have going on there already. $:^ ] Also, glad you hit the manual and try things -- I hope others learn from that...

First, quick little thing, you don't need self.id to get the id -- just id by itself will work (and in nearly every case, self is pretty useless fwiw).

Second, your actual issue.
  • What object is calling this code, and from what event? It kind of sounds like a controller (at x,y = 0,0 not accounting for +12*sign(image_xscale)) so far...
  • If that didn't solve it already, then what's your working code for side-by-side comparison?
  • And btw, (also if not solved already,) showing 0,0 in room (for which you'd likely need some good debugging to see) or 0,0 in the view?
Regards,
Bob $:^ J
So, I initially tried having the players emit the particles but it got too messy creating and destroying the system if say you wanted to restart the match or change characters because the particles would stop generating once the room restarted. So I have an object currently called partBlood that generates the onHit effects. It creates the particle type and system and everything and destroys everything at the end of the room. Then, from a script actually called onHit, it runs the following code on hitConfirm; the code is run from the player being hit, and "other" is the hitbox they're being hit by:

Code:
/*The prerequisites make it so certain types of hits avoid making this effect which can be seen in the OP. 
The spinning blade hits multiple times and as a result only makes the effect on the final hit, once "multiHit" has been set to false.*/
if !other.repeater && !other.multiHit
            if other.zone != "otg" || point_distance(x,y,atkr.x,atkr.y) < 80{
                    //__x and __y are the initial pixel point where the attackBox and hitbox make contact
                var xx = __x; var yy = __y;
                with (partBlood){
                    part_emitter_region(hitCon,blood,xx-4,xx+4,yy,yy-2,ps_shape_ellipse,ps_distr_gaussian);
                    part_emitter_burst(hitCon,spray,spark,1);
                    }
                }
As you can see, this works pretty well. I created a second object called partDust to handle the jump dust (friction dust, etc) and attempted to do the same thing. However, when it creates the particles, it's at the 0,0 position of the room (definitely the room, not the view).



I can pretty well figure out how to manipulate the particles to create good looking dust, but I can't even see how it looks effectively because it's in the corner of the room.
 

Drell

Member
Have you read this article I wrote a while back? Still relevant and a great place to start... http://www.yoyogames.com/blog/50

Other than that a few comments... first, there is almost never any reason to use "self". It's pretty much deprecated so stop using it and simply assign the "id" variable to the local variable. Second, are you sure you need an emitter? Maybe you should forget that and look at just using part_particles_create? In most simple cases an emitter isn't required and just bursting the particles with that function is fine (you can even do it over an area using repeat and a random set of positions).
So, switching it to particles_create solved the problem, but I still don't understand why. I don't understand how particles work fundamentally, still.

Also that article is what I read before I added the on hit effects. Thanks a bunch!
 
P

ParodyKnaveBob

Guest
Well, fwiw, to try to better understand what happened -- although I'm glad Nocturne helped you fix your issue! -- here's the part of your code you just posted which I want to compare:

Code:
//__x and __y are the initial pixel point where the attackBox and hitbox make contact
// PKB NOTE: meaning, apparently, that __x and __y are **player instance** variables
                var xx = __x; var yy = __y;
                with (partBlood){
                    part_emitter_region(hitCon,blood,xx-4,xx+4,yy,yy-2,ps_shape_ellipse,ps_distr_gaussian);
                    part_emitter_burst(hitCon,spray,spark,1);
                    }
                }
Therefore, it appears the partBlood object instance tells an emitter to resize/relocate using the player object instance's variables for hit detection. Whereas with the dust code...

Code:
var source = self.id;   
with (partBlood){
            part_emitter_region(colDust,jumpDust,source.x,source.x+12*sign(image_xscale),source.y,source.y,ps_shape_ellipse,ps_distr_gaussian);
            part_emitter_burst(colDust,dust,jumpDust,20);
            }
1. Now I don't know if you meant with (partBlood) or with (partDust).
2. I can guess from your description that you might intend for the player object instance to call this, but I still don't know what actually calls this with() construct. The fact that it seems to think x,y is at about 0,0 still makes me believe something like a controller is calling this. One good way to find out, if you want to call up your previous setup from a project backup...

Code:
var source = self.id;   
with (partBlood){
            show_debug_message("about to create dust, originally called from " + object_get_name(other.object_index) + " at coordinates " + string(other.x) + "," + string(other.y));
            part_emitter_region(colDust,jumpDust,source.x,source.x+12*sign(image_xscale),source.y,source.y,ps_shape_ellipse,ps_distr_gaussian);
            part_emitter_burst(colDust,dust,jumpDust,20);
            }
I hope this helps,
Bob
 

Drell

Member
1. Now I don't know if you meant with (partBlood) or with (partDust).
2. I can guess from your description that you might intend for the player object instance to call this, but I still don't know what actually calls this with() construct. The fact that it seems to think x,y is at about 0,0 still makes me believe something like a controller is calling this. One good way to find out, if you want to call up your previous setup from a project backup...

I hope this helps,
Bob
I had changed the particle to being created in partBlood for the sake of removing partDust as a variable in troubleshooting. I'm probably going to continue to do this and instead call the particles from scripts from a single partController. This is specifically to avoid running into any more issues with controllers.

That being said, I am now using part_particles_create() to create particles in a for loop which serves it's purpose, but isn't as easy to work with/immediately functional as an emitter would be.
What's confusing is that I'm not running the code any differently, just using part_particles_create() instead of the emitter:


Code:
var source = id;
                        with (partBlood){
                            for(i=0;i<12;i++)
                                part_particles_create(colDust,random_range(source.x-(12*i),source.x+(12*i)),source.bbox_bottom-21,jumpDust,3);
                            }
                        }
I'll likely end up creating something like genParticles(source,type,x,y,num) to handle this type of particle generation if emitters won't work, but I'd prefer not to have to.
 
Top