set_pause does not work on input_event

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tolikowski
:warning: Old Version Published before Godot 3 was released.

Hi,

I made a game where you have to shoot balloons. the collision detection is processed via _input_event() . 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)
:bust_in_silhouette: Reply From: mateusak

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

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 is_paused() function will always return false inside the input_event function.

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

Tolikowski | 2017-01-30 12:25