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

Particles3D: OneShot and Explosiveness dont work correctly #26042

Closed
kosz78 opened this issue Feb 19, 2019 · 10 comments
Closed

Particles3D: OneShot and Explosiveness dont work correctly #26042

kosz78 opened this issue Feb 19, 2019 · 10 comments
Assignees
Milestone

Comments

@kosz78
Copy link
Contributor

kosz78 commented Feb 19, 2019

Godot version:
Godot 3.1 commit 29fd942

OS/device including version:
Windows 10

Issue description:
Particles3D dont work as expected when set one shot and explosiveness > 0
I have created a simple scene with Animation Player that start/stop emitting particles
2019-02-19_11-21-17

Minimal reproduction project:
godot_particles_bug.zip

@kosz78 kosz78 changed the title Particles3D: OneShot and Exposiveness dont work correctly Particles3D: OneShot and Explosiveness dont work correctly Feb 19, 2019
@clayjohn
Copy link
Member

Please explain what were you expecting and how the results differ from that. A full explanation helps people understand your problem. Right now, everything looks correct in the gif you posted, so it is difficult to tell what needs to be fixed, if anything.

@kosz78
Copy link
Contributor Author

kosz78 commented Feb 19, 2019

When i play animation it should emit 2 times, but it emits sometimes one, sometimes nothing, it is very undeterminates.

@kosz78
Copy link
Contributor Author

kosz78 commented Feb 19, 2019

When set explosiveness to 0 all works as expected

@sketchyfun
Copy link
Contributor

sketchyfun commented Feb 20, 2019

I think what might be happening is all the particles are being emitted in the first shot, and so there's nothing to emit in the next shot. With a value of 8 particles and an explosive value of 0.8, it seems likely that all 8 particles would be fired within the time frame between first emission and the next emission, and since they haven't died before the next emission is triggered, the emitter emits nothing.

The amount value isn't how many will be emitted each frame, but more the target amount the emitter will try to create over time, based on the lifetime of the particles. I don't fully understand it, but that seems to be roughly how it works.

@clayjohn
Copy link
Member

@sketchyfun. Yea, thats more or less whats going on. Except setting "Emitting" off and on doesnt create another "shot". The shot refers to the lifetime. The "one shot" ends at the end of the particles life, not when "Emitting" is toggled.

Even though "Emitting" is turned off, the particles are still running. Turning "Emitting" off and on doesnt reset the particles. The lifetime is still 1 so the particles dont reset until 1 second has passed.

An explosiveness of 0.8 means that all particles are emitted within 0.2 seconds (because the lifetime is 1). So what you are seeing is the particles being emitted in a continuous stream for 0.2 seconds and then turning "Emitting" off and on does nothing because nothing would be emitted anyway.

When explosiveness is 0 the particles emit continuously so you turning "Emitting" on and off actually impacts whether the particles are emitted or not.

I hope that clears things up. This is not a bug, just a misunderstanding.

@jesperkondrup
Copy link

jesperkondrup commented Jun 18, 2019

Unfortunately this is also how I setup a lof of particles systems, so I have experienced the same issue many times (We are mainly working with CPUParticles and CPUParticles2D).

I also use One shot and explosiveness and then start them using the AnimationPlayer.
Usually it looks correct when the game is running if I call the "reset" function on a keyframe before emitting the particles BUT in the editor it almost never looks correct.

I think we could get better results if we had a "reset particles" that simply kills all particles. Then when you set emitting true it should start from the beginning. In Unity they have a "Stop" and a "Simulate" button.

@clayjohn
Copy link
Member

clayjohn commented Jun 19, 2019

@jesperkondrup What do you think about adding a bool restart_on_emit which, if set, would automatically call restart(). Whenever emitting is set to true. That way current behaviour can be maintained, but if you want to use flipping emitting on and off to restart the particle system you can.

CC @JFonS I would appreciate your thoughts as well

Sample implementation in CPUParticles: restart_on_emitting.txt

@jesperkondrup
Copy link

@clayjohn That sounds like a good idea, as long as it's also working when you start it from an AnimationPlayer.

@clayjohn
Copy link
Member

@jesperkondrup Actually I think the solution to this will be to solve #27146

Emitting should be able to turn on and off without restarting the particle simulation. My proposed solution was to turn this behaviour on and off with a bool. However, I think a proper solution is to fix the bug with restart() so that it actually restarts the particle system. Then, in your animation, instead of toggling emitting on and off, you would turn emitting off when you want it to stop emitting and then call restart() when you want it to restart()

@clayjohn
Copy link
Member

clayjohn commented Oct 3, 2019

Closing as fixed by #29974

I understand the workflow with animations is still not ideal as animations won't call methods in editor. However, that is not something that should be fixed in particles. It is something that should be addressed within the animation player.

@clayjohn clayjohn closed this as completed Oct 3, 2019
@akien-mga akien-mga added this to the 3.2 milestone Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants