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

Particles2D don't disable emitting after one-shot, when starting off-screen #32803

Open
Tracked by #61067
KoBeWi opened this issue Oct 13, 2019 · 8 comments
Open
Tracked by #61067

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Oct 13, 2019

Godot version:
3.2 alpha2

Issue description:
When you create Particles2D, enable one_shot and start emitting when particles are outside visible radius, the emitting is never disabled and will start only when particles are again on screen. This is annoying, because I wan't to e.g. play explosion, but are too far to see it and then it will happen when I get close, even though it should be already finished. One shot should affect emitting whether particles are rendering or not.

Steps to reproduce:

  1. Create Particles2D
  2. Enable one_shot
  3. Pan viewport away from particles
  4. Enable emitting
  5. Wait a bit
  6. Pan to particles again
  7. They will start emitting only then :<
@Ranoller
Copy link
Contributor

Maybe related: #18242

@KoBeWi
Copy link
Member Author

KoBeWi commented Nov 6, 2020

Still valid in 3.2.3
Will test in 4.0 when 2D particles are reintroduced.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 5, 2021

Still valid™ in 26b86c1

@Calinou
Copy link
Member

Calinou commented Jul 5, 2021

Related to #17903.

Can you reproduce this with GPUParticles3D located outside the camera frustum?

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 5, 2021

Yeah, same issue in 3D

@vfreitas-
Copy link

vfreitas- commented Apr 27, 2022

Still valid in 3.4.4-stable. Having the same issue =/

To help anybody with this issue:

To fix it I added a VisibilityNotifier2D to my explosion scene (where the Particles2D is the root) and changed my code to queue_free the scene if not emitting or if not on the screen.


func _ready():
	emitting = true
	one_shot = true
	
func _process(_delta):
	if not emitting or not $VisibilityNotifier2D.is_on_screen():
		queue_free()

Worked well for my case.

@svendixon
Copy link

I'm not sure this is really an issue. I know it seems like it's broken, it tripped me up.

But I think you should be using the particles visibility_rect for 2D, and visibility_aabb for 3D, here. This is what it's for. Your particle will run even if you go off screen and come back depending on how large the rect is. It's a bit silly, but one_shot particles in particular should probably have an almost infinitely large rect so the particle can run and finish even when it's far off the screen.

Performance shouldn't really be much of an issue here because they're one_shot particles that stop emitting after their lifetime ends and you can then queue_free() them if you want. However, if you have something generating these particles off screen, and you're worried about performance, you can use a VisibilityNotifier2D for 2D, or VisibilityNotifier for 3D, so they don't continue to create the particles when they themselves are off screen.

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 28, 2024

Seems like #20160 is related.

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

6 participants