GameMaker-Bugs
GameMaker-Bugs copied to clipboard
In-Game: particle_get_info() doesn't give a way of getting emitterIDs as of 2024.2
Description
Note: this issue exists in IDE version 2024.2.0.132, where I found the issue. I'm reporting this from IDE version 2023.11.1.129 because I had to move back to keep working on my project
Issue description: particle_get_info() returns information about a particle system, including emitters and their configuration. there's an "emitters" variable in the struct returned, which is an array containing structs with emitter-specific info for emitters in the system inspected.
however there's no index variable for being able to point to the system. This is a problem since Particle Systems assets (created through the Particle System Editor in the IDE) contain emitters with, now, no way to reference them through code to make them burst, or change their stream settings, during runtime.
Also note that in the past (v2023.11.1.129), the structs in the "emitters" array returned by particle_get_info() would work as an index themselves, but this isn't the case anymore in 2024.2.0.132.
This means that this code worked in v2023:
var getInfo = particle_get_info(ps_asset) part_emitter_stream(systemID, getInfo.emitters[0], partTypeID, amountInteger)
but it doesn't work now in v2024, getting the error: "part_emitter_stream argument 2 incorrect type (struct) expecting a particle emitter"
I'm attaching two screenshots of v2024.2.0.132, one showing in the debugger the contents of what's returned by particle_get_info(), where the emitterID is not present. the other screenshot shows the error message that happens when referencing the emitterInfo struct itself as an emitterID (which works in the last v2023, but doesn't in v2024)
Steps To Reproduce
Open GMS2 in version 2024.2.0.132: 1-Create a Particle System using the Particle System Editor that's part of the IDE. 2-Make sure to add at least one emitter using the editor. 3-Through code create an instance of that asset, using part_system_create_layer() or part_system_create(), store the ID of that PartSys instance 4-Use particle_get_info() to get a struct with information about the partSystem instance created in the step #3 5-From that struct, try to get the ID of the emitter configured in step #2, to be able to use it in, for example, part_emitter_stream() or part_emitter_burst().
Hello, I reported this through the IDE but I don't see the screenshots I attached through the reporter tool. Just in case, I'm leaving them here as imgur links:
#1 debugger view of contents of what particle_get_info() returns: https://i.imgur.com/i5TcK9n.png #2 runtime error when using the emitterInfo struct as an IDE (it works in v2023, but not in v2024): https://i.imgur.com/CF2naLS.png
Thanks for reporting this issue, but in order to investigate we will need a small project which shows this issue. Please report this issue again, but ensure you have a suitable project open at the time and you have checked the “Include Project” option on the bug form.
The issue here is that particle_get_info does not contain an emitter ID at all. This can be seen in the manual, no project needed. The particle type ID is accessible, but not the emitter ID.
Here, the particle type has an ind field to get the id:
But emitters do not:
As seen on this page: https://manual.gamemaker.io/monthly/en/index.htm#t=GameMaker_Language%2FGML_Reference%2FDrawing%2FParticles%2Fparticle_get_info.htm
While you can technically use the same number you use to access the emitter array (0, 1, 2, etc.), particle emitter ids are refs, not numbers, so this isn't really a "proper" or future proof way of doing it, since you have no way to get that actual ref value to use. In addition, using the number directly doesn't work for part_emitter_stream regardless. Here's a project that shows this, I set the emitter to "burst" in the asset editor, and then try to use part_emitter_stream, and no stream happens.
Other emitter specific functions like part_emitter_enable do work when passing an integer as the emitter argument.
The desired fix would be for it to be possible to do this:
part_emitter_stream(sys, getInfo.emitters[0].ind, getInfo.emitters[0].parttype.ind, 1);
Which you currently can't since no ind value exists in the emitter struct.
some more context: in 2023.11 particle_get_info() did not return any emitter ids either, it appears OP was getting lucky or something because in 2023.11 you get different results by using the emitter array or emitter array indices than you get in 2024.2.
this has some other consequences as well, for example part_emitter_enable() cannot be used with particle assets placed in the room editor because you cannot pass a particle asset reference to it.
it appears OP was getting lucky or something because in 2023.11 you get different results by using the emitter array or emitter array indices than you get in 2024.2.
Correct, hoping not to sound redundant, but just to confirm. In v2023.11, the "emitters" array inside the struct you get from particle_get_info() would hold structs that did work different, in that they could:
- A) Be read as a struct. You could read their internal variables, get particle type information, and so on. Just like the manual states.
- B) But also, be used as a ref for the emitter itself. i.e. it'd work for part_emitter_enable(), part_emitter_burst(), etc.
In v2024.2, they are only a struct and only A) remains true, and functions like part_emitter_stream() and part_emitter_region() will now tell you they specifically want an emitter ref instead of a struct.
In any case, if point B) was unintended and fixed/changed that's understandable, the real issue is as KormexGit mentions, in 2024.2 there's no current (or obvious, or documented) way to reach emitter indexes if they come from an asset created by the Particle System Editor.
This issue is preventing me from being able to use a good workflow with making particle systems and crafting emitters in the editor. I have to:
- Create the emitters in the editor
- Export the source of the system
- Paste the source into my code
- Create an array of pointers to the emitters from the pointers in the exported code
Anytime I make any edits to the emitters, I have to repaste the exported code into mine.
I'd be happy with:
- a function to find emitter IDs by name (so I can use the names from the returned ParticleEmitterInfo structures)
- having the emitter ID in the Particle Emitter Info structure
Please fix this, it really hinder Particle Editor functionality.
Big thanks for this. It is really appreciated! :)
Verified fixed in IDE v2024.800.0.598 Runtime v2024.800.0.621, using part_emitter_stream(sys, getInfo.emitters[0].ind, getInfo.emitters[0].parttype.ind, 1);.