tutorials/scripting/pausing_games #300
Replies: 2 comments
-
|
If you are looking for a function to just a subtree of nodes, here is a function that worked for me: func set_pause_subtree(root: Node, pause: bool) -> void:
var process_setters = ["set_process",
"set_physics_process",
"set_process_input",
"set_process_unhandled_input",
"set_process_unhandled_key_input",
"set_process_shortcut_input",]
for setter in process_setters:
root.propagate_call(setter, [!pause])Note that this will not stop _gui_input() for buttons and such. That can be done with something like |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Below is a script I wrote that can be attached to a node in a scene that will create a kind of pause mask that selects which objects to pause when certain input is received. Hope a feature like this will come standard before too long extends Node
@export var mask_groups: Array[String]
@export var input_action_name: String
var paused = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
if Input.is_action_just_pressed(input_action_name):
var children: Array[Node] = get_tree().current_scene.get_children()
for child: Node in children:
for mask in mask_groups:
if child.is_in_group(mask):
if paused:
child.process_mode = Node.PROCESS_MODE_INHERIT
else:
child.process_mode = ProcessMode.PROCESS_MODE_DISABLED
break
paused = !paused |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
tutorials/scripting/pausing_games
Introduction: In most games it is desirable to, at some point, interrupt the game to do something else, such as taking a break or changing options. Implementing a fine-grained control for what can ...
https://docs.godotengine.org/en/stable/tutorials/scripting/pausing_games.html
Beta Was this translation helpful? Give feedback.
All reactions