SceneTree

Manages the game loop via a hierarchy of nodes.

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.

@GodotBaseClass
struct SceneTree {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
GroupCallFlags
enum GroupCallFlags
StretchAspect
enum StretchAspect
StretchMode
enum StretchMode

Functions

_changeScene
void _changeScene(Node arg0)
_connectedToServer
void _connectedToServer()
_connectionFailed
void _connectionFailed()
_networkPeerConnected
void _networkPeerConnected(long arg0)
_networkPeerDisconnected
void _networkPeerDisconnected(long arg0)
_serverDisconnected
void _serverDisconnected()
callGroup
Variant callGroup(String group, String method, VarArgs varArgs)

Calls method on each member of the given group. You can pass arguments to method by specifying them at the end of the method call. Note: method may only have 5 arguments at most (7 arguments passed to this method in total). Note: callGroup will always call methods with an one-frame delay, in a way similar to GodotObject.callDeferred. To call methods immediately, use callGroupFlags with the constant GROUP_CALL_REALTIME flag.

callGroupFlags
Variant callGroupFlags(long flags, String group, String method, VarArgs varArgs)

Calls method on each member of the given group, respecting the given groupcallflags. You can pass arguments to method by specifying them at the end of the method call. Note: method may only have 5 arguments at most (8 arguments passed to this method in total). Note: Group call flags are used to control the method calling behavior. If the constant GROUP_CALL_REALTIME flag is present in the flags argument, methods will be called immediately. If this flag isn't present in flags, methods will be called with a one-frame delay in a way similar to callGroup.

changeScene
GodotError changeScene(String path)

Changes the running scene to the one at the given path, after loading it into a PackedScene and creating a new instance. Returns constant OK on success, constant ERR_CANT_OPEN if the path cannot be loaded into a PackedScene, or constant ERR_CANT_CREATE if that scene cannot be instantiated. Note: The scene change is deferred, which means that the new scene node is added on the next idle frame. You won't be able to access it immediately after the changeScene call.

changeSceneTo
GodotError changeSceneTo(PackedScene packed_scene)

Changes the running scene to a new instance of the given PackedScene. Returns constant OK on success or constant ERR_CANT_CREATE if the scene cannot be instantiated. Note: The scene change is deferred, which means that the new scene node is added on the next idle frame. You won't be able to access it immediately after the changeSceneTo call.

createTimer
Ref!SceneTreeTimer createTimer(double time_sec, bool pause_mode_process)

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. Commonly used to create a one-shot delay timer as in the following example:

getCurrentScene
Node getCurrentScene()
getEditedSceneRoot
Node getEditedSceneRoot()
getFrame
long getFrame()

Returns the current frame number, i.e. the total frame count since the application started.

getMultiplayer
Ref!MultiplayerAPI getMultiplayer()
getNetworkConnectedPeers
PoolIntArray getNetworkConnectedPeers()

Returns the peer IDs of all connected peers of this SceneTree's networkPeer.

getNetworkPeer
Ref!NetworkedMultiplayerPeer getNetworkPeer()
getNetworkUniqueId
long getNetworkUniqueId()

Returns the unique peer ID of this SceneTree's networkPeer.

getNodeCount
long getNodeCount()

Returns the number of nodes in this SceneTree.

getNodesInGroup
Array getNodesInGroup(String group)

Returns a list of all nodes assigned to the given group.

getRoot
Viewport getRoot()
getRpcSenderId
long getRpcSenderId()

Returns the sender's peer ID for the most recently received RPC call.

hasGroup
bool hasGroup(String name)

Returns true if the given group exists.

hasNetworkPeer
bool hasNetworkPeer()

Returns true if there is a networkPeer set.

isDebuggingCollisionsHint
bool isDebuggingCollisionsHint()
isDebuggingNavigationHint
bool isDebuggingNavigationHint()
isInputHandled
bool isInputHandled()

Returns true if the most recent InputEvent was marked as handled with setInputAsHandled.

isMultiplayerPollEnabled
bool isMultiplayerPollEnabled()
isNetworkServer
bool isNetworkServer()

Returns true if this SceneTree's networkPeer is in server mode (listening for connections).

isPaused
bool isPaused()
isRefusingNewNetworkConnections
bool isRefusingNewNetworkConnections()
isUsingFontOversampling
bool isUsingFontOversampling()
notifyGroup
void notifyGroup(String group, long notification)

Sends the given notification to all members of the group.

notifyGroupFlags
void notifyGroupFlags(long call_flags, String group, long notification)

Sends the given notification to all members of the group, respecting the given groupcallflags.

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(SceneTree other)
opEquals
bool opEquals(typeof(null) n)
queueDelete
void queueDelete(GodotObject obj)

Queues the given object for deletion, delaying the call to GodotObject.free to after the current frame.

quit
void quit(long exit_code)

Quits the application at the end of the current iteration. A process exit_code can optionally be passed as an argument. If this argument is 0 or greater, it will override the OS.exitCode defined before quitting the application. Note: On iOS this method doesn't work. Instead, as recommended by the iOS Human Interface Guidelines, the user is expected to close apps via the Home button.

reloadCurrentScene
GodotError reloadCurrentScene()

Reloads the currently active scene. Returns constant OK on success, constant ERR_UNCONFIGURED if no currentScene was defined yet, constant ERR_CANT_OPEN if currentScene cannot be loaded into a PackedScene, or constant ERR_CANT_CREATE if the scene cannot be instantiated.

setAutoAcceptQuit
void setAutoAcceptQuit(bool enabled)

If true, the application automatically accepts quitting. Enabled by default. For mobile platforms, see setQuitOnGoBack.

setCurrentScene
void setCurrentScene(Node child_node)
setDebugCollisionsHint
void setDebugCollisionsHint(bool enable)
setDebugNavigationHint
void setDebugNavigationHint(bool enable)
setEditedSceneRoot
void setEditedSceneRoot(Node scene)
setGroup
void setGroup(String group, String property, VariantArg2 value)

Sets the given property to value on all members of the given group.

setGroupFlags
void setGroupFlags(long call_flags, String group, String property, VariantArg3 value)

Sets the given property to value on all members of the given group, respecting the given groupcallflags.

setInputAsHandled
void setInputAsHandled()

Marks the most recent InputEvent as handled.

setMultiplayer
void setMultiplayer(MultiplayerAPI multiplayer)
setMultiplayerPollEnabled
void setMultiplayerPollEnabled(bool enabled)
setNetworkPeer
void setNetworkPeer(NetworkedMultiplayerPeer peer)
setPause
void setPause(bool enable)
setQuitOnGoBack
void setQuitOnGoBack(bool enabled)

If true, the application quits automatically on going back (e.g. on Android). Enabled by default. To handle 'Go Back' button when this option is disabled, use constant MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST.

setRefuseNewNetworkConnections
void setRefuseNewNetworkConnections(bool refuse)
setScreenStretch
void setScreenStretch(long mode, long aspect, Vector2 minsize, double shrink)

Configures screen stretching to the given stretchmode, stretchaspect, minimum size and shrink ratio.

setUseFontOversampling
void setUseFontOversampling(bool enable)
toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

currentScene
Node currentScene [@property getter]
Node currentScene [@property setter]

The current scene.

debugCollisionsHint
bool debugCollisionsHint [@property getter]
bool debugCollisionsHint [@property setter]

If true, collision shapes will be visible when running the game from the editor for debugging purposes.

debugNavigationHint
bool debugNavigationHint [@property getter]
bool debugNavigationHint [@property setter]

If true, navigation polygons will be visible when running the game from the editor for debugging purposes.

editedSceneRoot
Node editedSceneRoot [@property getter]
Node editedSceneRoot [@property setter]

The root of the edited scene.

multiplayer
MultiplayerAPI multiplayer [@property getter]
MultiplayerAPI multiplayer [@property setter]

The default MultiplayerAPI instance for this SceneTree.

multiplayerPoll
bool multiplayerPoll [@property getter]
bool multiplayerPoll [@property setter]

If true (default value), enables automatic polling of the MultiplayerAPI for this SceneTree during idleFrame. If false, you need to manually call MultiplayerAPI.poll to process network packets and deliver RPCs/RSETs. This allows running RPCs/RSETs in a different loop (e.g. physics, thread, specific time step) and for manual Mutex protection when accessing the MultiplayerAPI from threads.

networkPeer
NetworkedMultiplayerPeer networkPeer [@property getter]
NetworkedMultiplayerPeer networkPeer [@property setter]

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 isNetworkServer) and will set the root node's network mode to master, or it will become a regular peer with the 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.

paused
bool paused [@property getter]
bool paused [@property setter]

If true, the SceneTree is paused. Doing so will have the following behavior: - 2D and 3D physics will be stopped. - Node._process, Node._physicsProcess and Node._input will not be called anymore in nodes.

refuseNewNetworkConnections
bool refuseNewNetworkConnections [@property getter]
bool refuseNewNetworkConnections [@property setter]

If true, the SceneTree's networkPeer refuses new incoming connections.

root
Viewport root [@property getter]

The SceneTree's root Viewport.

useFontOversampling
bool useFontOversampling [@property getter]
bool useFontOversampling [@property setter]

If true, font oversampling is used.

Static functions

_new
SceneTree _new()

Construct a new instance of SceneTree. Note: use memnew!SceneTree instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta