-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Add finished
signal to CPUParticles
#76853
Add finished
signal to CPUParticles
#76853
Conversation
bed8032
to
92f1f78
Compare
Just noticed that this breaks the resetting of |
92f1f78
to
1b03ec9
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works quite well for the most part. However, if emitting is set to true
in the same frame that the particle is created (or the same frame that the particle is restarted), the signal will fire immediately. You probably need to also check if cycle is 0 or if time == 0.
I tested with a very simple script in a scene with a default CPUParticles2D node set to one_shot
extends Node2D
func _ready():
$CPUParticles2D.emission_finished.connect(finished_emitt)
$CPUParticles2D.restart() # this emits the signal in the first frame, but not when emission actually finishes
# $CPUParticles2D.call_deferred("restart") # this works
func finished_emitt():
print("done emitting")
$Sprite2D.visible = false
This seems to happen if restarting in Checking for time not to be zero as proposed by you seems to work. |
1b03ec9
to
29ba41b
Compare
It looks like the particles will process when delta time is 0 if the edit: oops, I started this message in response to your message before getting edited. I think just checking time will result in issues when using pre_process |
All preprocessing happens while time == 0 so the signal cannot be emmitted during pre processing. But after this it seems to work fine for me. Even if preprocess is higher than lifetime the internal processing will only be turned of after the signal gets emitted so internal process will run and the signal is emitted emediately. If you find another case that makes problems with pre process I will look into it. |
Ah, of course. You are right. It will never signal during the pre_process which is a good thing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with this implementation. I have tested locally and it appears to work well.
This should be a great early inclusion to 4.2.
Note for merger, this should be merged at the same time as its counterpart #76859 (for GPUParticles) which I still need to test/review
emission_finished
signal to CPUParticles.
emission_finished
signal to CPUParticles.emission_finished
signal to CPUParticles
29ba41b
to
a1c0d20
Compare
emission_finished
signal to CPUParticlesfinished
signal to CPUParticles
Thanks! |
Closes godotengine/godot-proposals#649.
Can be tested with this project.