Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

SceneTree

Inherits: MainLoop < Object

Manages the game loop via a hierarchy of nodes.

Description

As one of the most important classes, the SceneTree manages the hierarchy of nodes in a scene as well as scenes themselves. Nodes can be added, retrieved and removed. The whole scene tree (and thus the current scene) can be paused. Scenes can be loaded, switched and reloaded.

You can also use the SceneTree to organize your nodes into groups: every node can be assigned as many groups as you want to create, e.g. an "enemy" group. You can then iterate these groups or even call methods and set properties on all the group's members at once.

SceneTree is the default MainLoop implementation used by scenes, and is thus in charge of the game loop.

Tutorials

Properties

bool

auto_accept_quit

true

Node

current_scene

bool

debug_collisions_hint

false

bool

debug_navigation_hint

false

bool

debug_paths_hint

false

Node

edited_scene_root

bool

multiplayer_poll

true

bool

paused

false

bool

quit_on_go_back

true

Window

root

Methods

void

call_group ( StringName group, StringName method, ... ) vararg

void

call_group_flags ( int flags, StringName group, StringName method, ... ) vararg

Error

change_scene_to_file ( String path )

Error

change_scene_to_packed ( PackedScene packed_scene )

SceneTreeTimer

create_timer ( float time_sec, bool process_always=true, bool process_in_physics=false,