Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

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, fetched 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 added to 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 nodes belonging to any given group.

SceneTree is the default MainLoop implementation used by the engine, 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(group: StringName, method: StringName, ...) vararg

void

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

Error

change_scene_to_file(path: String)

Error

change_scene_to_packed(packed_scene: PackedScene)

SceneTreeTimer

create_timer(time_sec: float, process_always: bool = true, process_in_physics: bool = false, ignore_time_scale: bool = false)

Tween

create_tween()

Node

get_first_node_in_group(group: StringName)

int

get_frame() const

MultiplayerAPI

get_multiplayer(for_path: NodePath = NodePath("")) const

int

get_node_count() const

int

get_node_count_in_group(group: StringName) const

Array[Node]

get_nodes_in_group(group: StringName)

Array[Tween]

get_processed_tweens()

bool

has_group(name: StringName) const

void

notify_group(group: StringName, notification: int)

void

notify_group_flags(call_flags: int, group: StringName, notification: int)

void

queue_delete(obj: Object)

void

quit(exit_code: int = 0)

Error

reload_current_scene()