godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.08k stars 69 forks source link

Add "Emit on Load" to particles #8590

Open Araraura opened 7 months ago

Araraura commented 7 months ago

Describe the project you are working on

a platformer with heavy use of particles

Describe the problem or limitation you are having in your project

I use a lot of particles with "Oneshot" enabled. When I preload such a particle and instantiate it in the scene tree, I will have to make sure to set emitting to true in code for the particles to start, and in some cases create a scene specific to the particles and use an animationplayer to emit the particles on load.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Particle nodes should have an "Emit on Load" flag.

Pretty self explanatory - when the node/scene/particles instantiate, the particles automatically start emitting

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

There should be a checkbox under the "Time" category of the particles with this setting, probably next to "Oneshot"

If this enhancement will not be used often, can it be worked around with a few lines of script?

yes, though it can get cumbersome when a project has lots of different particles used in different scenarios.

Is there a reason why this should be core and not an add-on in the asset library?

Particle systems are a part of Godot.

Calinou commented 7 months ago

I suggest enabling Emitting, disabling Oneshot and queue_free()ing the particles once they're done emitting once in this case. If you spawn them through an AnimationPlayer, you can free the node once the animation is done playing (add some buffer to its length, so it doesn't free the particles before they're all done emitting).

ettiSurreal commented 6 months ago

Adding to that, you can have particles with oneshot start emitting automatically, by directly setting emitting to true directly in the scene file. However having to do that is cumbersome, and if you wanna make changes (or just simply open the scene and accidentally save), emitting is automatically set to false so you'll have to edit the file again. Besides, AudioStreamPlayers already have an autostart property that would be the equivalent to this, so +1.

4X3L82 commented 1 month ago

I suggest enabling Emitting, disabling Oneshot and queue_free()ing the particles once they're done emitting once in this case.

But with Oneshot disabled, when/how would you find out if/when they are done emitting?

Docs:

finished ( ) Emitted when all active particles have finished processing. When one_shot is disabled, particles will process continuously, so this is never emitted.

With Oneshot disabled, the particles will never be "done".

ettiSurreal commented 1 month ago

Docs:

finished ( ) Emitted when all active particles have finished processing. When one_shot is disabled, particles will process continuously, so this is never emitted.

With Oneshot disabled, the particles will never be "done".

See https://github.com/godotengine/godot-proposals/issues/9073