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, 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, bool ignore_time_scale=false )

Tween

create_tween ( )

Node

get_first_node_in_group ( StringName group )

int

get_frame ( ) const

MultiplayerAPI

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

int

get_node_count ( ) const

Node[]

get_nodes_in_group ( StringName group )

Tween[]

get_processed_tweens ( )

bool

has_group ( StringName name ) const

void

notify_group ( StringName group, int notification )

void

notify_group_flags ( int call_flags, StringName group, int notification )

void

queue_delete ( Object obj )

void

quit ( int exit_code=0 )

Error

reload_current_scene ( )

void