0 votes

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
Godot version v3.4.stable.official [206ba70f4]
in Engine by (95 points)
edited by

1 Answer

0 votes

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)

by (74 points)

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 :/

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

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.