SceneTree manages a hierarchy of nodes.
- connected_to_server ( )
Emitted whenever this SceneTree’s network_peer successfully connected to a server. Only emitted on clients.
- connection_failed ( )
Emitted whenever this SceneTree’s network_peer fails to establish a connection to a server. Only emitted on clients.
Emitted whenever files are drag-and-dropped onto the window.
- idle_frame ( )
Emitted immediately before Node._process is called on every node in the SceneTree.
- network_peer_connected ( int id )
Emitted whenever this SceneTree’s network_peer connects with a new peer. ID is the peer ID of the new peer. Clients get notified when other clients connect to the same server. Upon connecting to a server, a client also receives this signal for the server (with ID being 1).
- network_peer_disconnected ( int id )
Emitted whenever this SceneTree’s network_peer disconnects from a peer. Clients get notified when other clients disconnect from the same server.
- node_added ( Node node )
Emitted whenever a node is added to the SceneTree.
- node_configuration_warning_changed ( Node node )
Emitted when a node’s configuration changed. Only emitted in tool mode.
- node_removed ( Node node )
Emitted whenever a node is removed from the SceneTree.
- physics_frame ( )
Emitted immediately before Node._physics_process is called on every node in the SceneTree.
- screen_resized ( )
Emitted whenever the screen resolution (fullscreen) or window size (windowed) changes.
- server_disconnected ( )
Emitted whenever this SceneTree’s network_peer disconnected from server. Only emitted on clients.
- tree_changed ( )
Emitted whenever the SceneTree hierarchy changed (children being moved or renamed, etc.).
- GROUP_CALL_DEFAULT = 0 — Call a group with no flags (default).
- GROUP_CALL_REVERSE = 1 — Call a group in reverse scene order.
- GROUP_CALL_REALTIME = 2 — Call a group immediately (calls are normally made on idle).
- GROUP_CALL_UNIQUE = 4 — Call a group only once even if the call is executed many times.
- STRETCH_MODE_DISABLED = 0 — No stretching.
- STRETCH_MODE_2D = 1 — Render stretching in higher resolution (interpolated).
- STRETCH_MODE_VIEWPORT = 2 — Keep the specified display resolution. No interpolation. Content may appear pixelated.
- STRETCH_ASPECT_IGNORE = 0 — Fill the window with the content stretched to cover excessive space. Content may appear elongated.
- STRETCH_ASPECT_KEEP = 1 — Retain the same aspect ratio by padding with black bars in either axes. No expansion of content.
- STRETCH_ASPECT_KEEP_WIDTH = 2 — Expand vertically. Left/right black bars may appear if the window is too wide.
- STRETCH_ASPECT_KEEP_HEIGHT = 3 — Expand horizontally. Top/bottom black bars may appear if the window is too tall.
- STRETCH_ASPECT_EXPAND = 4 — Expand in both directions, retaining the same aspect ratio. No black bars.
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. a “enemy” group. You can then iterate these groups or even call methods and set properties on all the group’s members at once.
- Node current_scene
The current scene.
- bool debug_collisions_hint
- Node edited_scene_root
The root of the edited scene.
- MultiplayerAPI multiplayer
The default MultiplayerAPI instance for this SceneTree.
- bool multiplayer_poll
false you need to manually call MultiplayerAPI.poll for processing network packets and delivering RPCs/RSETs. This allows to run RPCs/RSETs in a different loop (e.g. physics, thread, specific time step) and for manual Mutex protection when accessing the MultiplayerAPI from threads.
- NetworkedMultiplayerPeer network_peer
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the SceneTree will become a network server (check with is_network_server()) and will set root node’s network mode to master (see NETWORK_MODE_* constants in Node), or it will become a regular peer with root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to SceneTree’s signals.
- bool paused
true the SceneTree is paused.
- bool refuse_new_network_connections
true the SceneTree’s network_peer refuses new incoming connections.
- Viewport root
The SceneTree’s Viewport.
- bool use_font_oversampling
true font oversampling is used.
method on each member of the given group.
method on each member of the given group, respecting the given GroupCallFlags.
Changes to the scene at the given
Changes to the given PackedScene.
Returns a SceneTreeTimer which will SceneTreeTimer.timeout after the given time in seconds elapsed in this SceneTree. If
pause_mode_process is set to false, pausing the SceneTree will also pause the timer.
- int get_frame ( ) const
- PoolIntArray get_network_connected_peers ( ) const
Returns the peer IDs of all connected peers of this SceneTree’s network_peer.
- int get_network_unique_id ( ) const
Returns the unique peer ID of this SceneTree’s network_peer.
- int get_node_count ( ) const
Returns the number of nodes in this SceneTree.
Returns all nodes assigned to the given group.
- int get_rpc_sender_id ( ) const
Returns the sender’s peer ID for the most recently received RPC call.
true if the given group exists.
- bool has_network_peer ( ) const
true if there is a network_peer set.
- bool is_input_handled ( )
true if the most recent InputEvent was marked as handled with set_input_as_handled.
- bool is_network_server ( ) const
true if this SceneTree’s network_peer is in server mode (listening for connections).
Sends the given notification to all members of the
Sends the given notification to all members of the
group, respecting the given GroupCallFlags.
- void queue_delete ( Object obj )
Queues the given object for deletion, delaying the call to Object.free to after the current frame.
- void quit ( )
Quits the application.
- Error reload_current_scene ( )
Reloads the currently active scene.
- void set_auto_accept_quit ( bool enabled )
true the application automatically accepts quitting.
Sets the given
value on all members of the given group.
Sets the given
value on all members of the given group, respecting the given GroupCallFlags.
- void set_input_as_handled ( )
Marks the most recent input event as handled.
- void set_quit_on_go_back ( bool enabled )
true the application quits automatically on going back (e.g. on Android).
Configures screen stretching to the given StretchMode, StretchAspect, minimum size and