0 votes

Hi,

I made a game where you have to shoot balloons. the collision detection is processed via inputevent() . but whenever I pause the game and tap on one of the balloons, the process is just postponed to when I deactivate the pause mode.

How can I fix this?

Here my code to the pause button:

func _on_pause_pressed():

    if !get_tree().is_paused():
        get_tree().set_pause(true)

    elif get_tree().is_paused():
        get_tree().set_pause(false)
in Engine by (17 points)

1 Answer

0 votes

There's get_tree().is_paused(), you can check it in the beggining and return if it's false (like you just did to pause it in the first place).

So, like:

func input_event():    
   if get_tree().is_paused():
      return  
   #code
by (1,087 points)
edited by

Unfortunately that didn't work... I guess that when you pause the game, you automatically freeze all nodes. So in the moment you pause the game, the ispaused() function will always return false inside the inputevent function.

Is there a way to delay the setpaused() function so I can first disable the input before going into paused mode? It seems that when the button is pressed, the setpaused() function is always firing first.

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.