particles over my draw event

Didjynn

Member
Hello everyone,

I have an object drawing some sprites and emetting some particles. The particles options are set in the create event.

The first game, particles are under all my sprites, which is what I want. But if I make another game/match, the particles are over it.

In the create event I use
Code:
part_system_depth(gel, depth + 5);
to set the depth of my particles which should always be under my sprites drawn, do I mistake ?

Also, at the end of a match, I change the room and my instance isn't set as persistent. Also I have
Code:
part_type_destroy(gel)
part_system_destroy(create_particles_gel)
in the destroy AND room change event. So I don't see how they could persist after the end of a match.

I've been looking for this problem for monthes now and I never found the reason for it, it just makes no sens to me. I tried +5 and -5 depth, I tried to set the depth each step to see if something change. But no, just the first match it is under the drawn sprites and after that above it.

Any idea ? I'm dying of frustration here
 

samspade

Member
Hello everyone,

I have an object drawing some sprites and emetting some particles. The particles options are set in the create event.

The first game, particles are under all my sprites, which is what I want. But if I make another game/match, the particles are over it.

In the create event I use
Code:
part_system_depth(gel, depth + 5);
to set the depth of my particles which should always be under my sprites drawn, do I mistake ?

Also, at the end of a match, I change the room and my instance isn't set as persistent. Also I have
Code:
part_type_destroy(gel)
part_system_destroy(create_particles_gel)
in the destroy AND room change event. So I don't see how they could persist after the end of a match.

I've been looking for this problem for monthes now and I never found the reason for it, it just makes no sens to me. I tried +5 and -5 depth, I tried to set the depth each step to see if something change. But no, just the first match it is under the drawn sprites and after that above it.

Any idea ? I'm dying of frustration here
What does make another game/match mean? Are you using room_restart, game_restart, room_goto, manually doing everything?
Is this GMS 1 or 2? Are you using the clean up function?

Have you run the debugger? What does it say about objects existing - remember that this can be tricky with dynamic resources as you could destroy the object, but the thing can still exist if it was not destroyed. And you could have no reference to it meaning it won't show up anywhere (that I know of) and you'll have no way of interacting with it in the future.

part_system_depth(gel, depth + 5); won't really do anything except set the depth of the particle system to the depth of the object it is in plus five. This is meaningless without knowing the depth of the object and all other objects - e.g. it doesn't matter much if its depth goes from from 10 to 15 if the other depths are 100. In most cases I think you should be choosing the depth you want.
 

Didjynn

Member
Another game mean a room change here. I'm in the menu, which is a romm then I launch a match, for this I change the room. At the end of the match, I change to the main menu room.

I'm using room_goto.

It is GMS 2 and I am not using the clean up function (after reading what it does, I think using "destroy" event and "room change" event are enough.

I used part_system_depth(gel, depth + 5); in the object drawing the sprites. In the logic, what I draw is drawn at the depth of my object. So if I set my particles depth higher, they should be under my object, not above (and it works fine the first time).

I don't think it can come from object destroyed but still existing for many reasons. One of them is I can have from 2 to 6 players. Each of them set its own variable, depth and particles. If I play a 2 player game, it works fine since it is the first game. Then I leave and come back (or win and come back, doesn't change anything) and set the number of players > 2 and the new players created have the same problem than the 2 first ones : from the 2nd game, particles are above the player, not under.
 

samspade

Member
Another game mean a room change here. I'm in the menu, which is a romm then I launch a match, for this I change the room. At the end of the match, I change to the main menu room.

I'm using room_goto.

It is GMS 2 and I am not using the clean up function (after reading what it does, I think using "destroy" event and "room change" event are enough.

I used part_system_depth(gel, depth + 5); in the object drawing the sprites. In the logic, what I draw is drawn at the depth of my object. So if I set my particles depth higher, they should be under my object, not above (and it works fine the first time).

I don't think it can come from object destroyed but still existing for many reasons. One of them is I can have from 2 to 6 players. Each of them set its own variable, depth and particles. If I play a 2 player game, it works fine since it is the first game. Then I leave and come back (or win and come back, doesn't change anything) and set the number of players > 2 and the new players created have the same problem than the 2 first ones : from the 2nd game, particles are above the player, not under.
I would still use the clean up function, but I think you're right that the destroy function will be triggered in this case. It sounds like you're using a particle system for each object, and while that's not really that bad, it probably isn't that good either. You lose some of the efficiency, make it harder to debug, increase the chance of memory leaks, etc.

My guess is if you had a single dedicated particle system object which was non persistent, used its own layer, and used the clean up event the problem would go away. Although I'm sure you can also make it work your way as well. I would just start running the debugger and checking the values to make sure everything is doing what you think it is supposed to.
 

Didjynn

Member
I found my problem, I had it under the eyes since the beginning but it's something I wasn't checking ... considered it was right when it wasn't.
I was checking the particle type instead of the particle system. Thanks for your help ! :D
 
Last edited:
Top