I have a Pause function that is failing to work, I have the function in an autoload. and i have the nodes i want to pause in a “Pausable” group. when i press my action key, I get my print output to confirm its pressed and also get the output to tell me its got the nodes, but nothing pauses.
my Autoloaded code,
extends Node2D
var missHit = false
var currentTanks = 0
var maxHealth = 1000
var minHealth = 0
var health:int = 1000
var score:int = 0
var timeSurvived:int = 0
func set_pause(pause: bool):
var nodes = get_tree().get_nodes_in_group(“Pausable”)
for node in nodes:
node.set_process(!pause)
node.set_physics_process(!pause)
if node == null:
print(“Cant get Nodes”)
else:
print(“Got Nodes”)
func _process(delta):
if Input.is_action_just_pressed(“pause”):
print(“Pause pressed”)
set_pause(true)
if Input.is_action_just_pressed(“unpause”):
print(“Pause pressed”)
set_pause(false)
if health > maxHealth:
health = maxHealth
if health < minHealth:
health = minHealth
Okay, I’ve now found that although the node containing this script is set to process always, it was not processing after the pause, adding this line, fixed the issue.