Particles2D with uncontrollable pause mode

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By haha-lolcat1

hi all,

for some reason when I set get_tree().paused = true, I can’t control the particles2d pause process.

for example, if I have a moving sprite (controlled by Tween) and an ongoing particles2d object, if I set both nodes to .pause_mode = 2 during the pause, the sprite will start moving again, but particles2d won’t.

why is that?

here is a code example:

func _input(event):
	if event.is_action_pressed("ui_cancel"):
		get_tree().paused = !get_tree().paused
	
	if event.is_action_pressed("ui_accept"):
		$Particles2D.pause_mode = 1
		$Tween.pause_mode = 1
	
	if event.is_action_pressed("ui_select"):
		$Particles2D.pause_mode = 2 ## does not resume particles during pause
		$Tween.pause_mode = 2 ## resumes the sprite movement during pause
:bust_in_silhouette: Reply From: PhantomPixel

Why node just use get_tree().paused to pause the game, then for the objects that you don’t want to pause just set their pause mode to process(found by clicking on the node, then the scroll down to the bottom in the Inspector window)

it might be bit complicated to explain, but from the PauseMenu I can either quit to the MainMenu (change_scene()) or Exit the game (get_tree().quit()).
When either of these happens, there is a fade out animation playing.
During this fade out, I need everything to be paused, except for the particles animation.
But during the actual pause (when PauseMenu is displayed), these particles must be paused.

Since Godot does not have an individual pause() functionality, I am looking for a workaround using pause_mode, but it seems that it may be related to the fact the the resource material is also being paused :confused:

haha-lolcat1 | 2022-01-04 17:48

Then would this work?:

  • setting the particles to process
  • using the .visible property to display the particles when needed
  • using a black sprite then adjusting it’s transparency, then using .visible again on the sprite

PhantomPixel | 2022-01-09 07:14

well, I always need them to be visible, either animated or frozen, depending on the conditions.
I think it has to do with the resource material being paused, because the Particles2D node itself works as it should (I think)
I ended up manually playing with the pause mode and unpausing like so:

func semi_process():
	$Rain.pause_mode = 2
	$YSort/House1/RainParticles.pause_mode = 2
	$YSort/House2/RainParticles.pause_mode = 2
	$YSort/House3/RainParticles.pause_mode = 2
	$YSort/House4/RainParticles.pause_mode = 2
	get_tree().paused = false
	get_tree().paused = true #I hate this
	$YSort/House1/RainParticles.pause_mode = 0
	$YSort/House2/RainParticles.pause_mode = 0
	$YSort/House3/RainParticles.pause_mode = 0
	$YSort/House4/RainParticles.pause_mode = 0

get_tree().paused = false and then true happens so rapidly, that it is visually seemless to the user. so as stupid as it is, it works.

haha-lolcat1 | 2022-01-13 03:59