Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically adjust the amount of particles emitted without clearing all the particles #5939

Open
chrisb123 opened this issue Dec 15, 2022 · 3 comments · May be fixed by godotengine/godot#70145

Comments

@chrisb123
Copy link

chrisb123 commented Dec 15, 2022

Describe the project you are working on

Change the amount of particles to visually indicate a change that does involve clearing existing particles

Describe the problem or limitation you are having in your project

Tho only way to change the amount of particles is to change the total amount which clears all particles

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

Don't emit particles based on a user provided ratio. Particles live out their life as normal, when they are due for restart they are tested based the ratio they are not submitted

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

User enters a ratio number, eg. 0.01 means 1% of amount and 1.00 would be every particle.
The default is 1 to avoid breaking existing projects

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

It's particles best to fix this in engine. I have no idea of any other suitable solution

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

I have no idea how to efficiently solve this except for core.
I have a working example in engine for cpu particles 2D & 3D that has this feature

https://discord.com/channels/212250894228652034/218361207990648832/1052569941888475136

image

@clayjohn
Copy link
Member

It should be fairly straightforward to expose something like MultiMesh's visible_instance_count to quickly change the number of particles visible. I guess a downside is that the invisible particles would still get processed, but I guess that is desirable so that you can change the number without restarting

@chrisb123
Copy link
Author

If that is the case I am probably misunderstanding or missing something with how the process works, my solution required me to evenly distribute and disable particles in the array of all particles. For example to show 50% I had to disable every second particle not only show the first 50%. There may be a better solution or more that can be disabled in addition to what I have done but I found that CPU usage did drop a little when particle ratio was lowered

@chrisb123
Copy link
Author

chrisb123 commented Dec 16, 2022

CPU particles 3D ratio also completed
GPU particles is different to the CPU, I have not looked into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants