Ok, Update on this I finished my stop time:
https://gfycat.com/WhirlwindAcrobaticGuanaco
So I wanna to share my approach.
Basically is based on the solution proposed by zendorf of a global var with quality of life modifications.
First you make a node with a script, on my case is local from stage nodes, not a global script with autoload.
On that class you put your var for frozen, on my case is a bool, but also you make this var a setget. Why is that, because you could emit a signal when the var is changed and notify all the registered objects, this solution work with animations for example and the fixed updates or collisions using the bool directly.
My code look like this:
extends Node
#When this var is set to true, all enemies and bullets should freeze with the exception of player
var zawarudo = false setget _set_zawarudo
signal zawarudo_start()
signal zawarudo_stop()
func _ready():
pass
func _set_zawarudo(value):
if(zawarudo != value):
zawarudo = value
if(zawarudo):
emit_signal("zawarudo_start")
else:
emit_signal("zawarudo_stop")
And as an example I used it to stop an animation player here:
extends AnimationPlayer
#Class for pause animation players on zawarudo effect
var _zawarudo
func _ready():
_zawarudo = get_tree().get_nodes_in_group("_zawarudo")[0]
if(!_zawarudo.is_connected("zawarudo_start", self, "_zawarudo_start")):
_zawarudo.connect("zawarudo_start", self, "_zawarudo_start")
if(!_zawarudo.is_connected("zawarudo_stop", self, "_zawarudo_stop")):
_zawarudo.connect("zawarudo_stop", self, "_zawarudo_stop")
if(_zawarudo.zawarudo):
_zawarudo_start()
func _zawarudo_start():
if(is_active()):
set_active(false)
func _zawarudo_stop():
if(!is_active()):
set_active(true)
Note I use a group for the access to the zawarudo class.