Documentation
¶
Overview ¶
Nodes are Godot's building blocks. They can be assigned as the child of another node, resulting in a tree arrangement. A given node can contain any number of nodes as children with the requirement that all siblings (direct children of a node) should have unique names.
A tree of nodes is called a scene. Scenes can be saved to the disk and then instantiated into other scenes. This allows for very high flexibility in the architecture and data model of Godot projects.
Scene tree: The SceneTree contains the active tree of nodes. When a node is added to the scene tree, it receives the NotificationEnterTree notification and its EnterTree callback is triggered. Child nodes are always added after their parent node, i.e. the EnterTree callback of a parent node will be triggered before its child's.
Once all nodes have been added in the scene tree, they receive the NotificationReady notification and their respective Ready callbacks are triggered. For groups of nodes, the Ready callback is called in reverse order, starting with the children and moving up to the parent nodes.
This means that when adding a node to the scene tree, the following order will be used for the callbacks: EnterTree of the parent, EnterTree of the children, Ready of the children and finally Ready of the parent (recursively for the entire scene tree).
Processing: Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback Process, toggled with SetProcess) happens as fast as possible and is dependent on the frame rate, so the processing time delta (in seconds) is passed as an argument. Physics processing (callback PhysicsProcess, toggled with SetPhysicsProcess) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine.
Nodes can also process input events. When present, the Input function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the UnhandledInput function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI Control nodes), ensuring that the node only receives the events that were meant for it.
To keep track of the scene hierarchy (especially when instantiating scenes into other scenes), an "owner" can be set for the node with the Owner property. This keeps track of who instantiated what. This is mostly useful when writing editors and tools, though.
Finally, when a node is freed with Object.Free or QueueFree, it will also free all its children.
Groups: Nodes can be added to as many groups as you want to be easy to manage, you could create groups like "enemies" or "collectables" for example, depending on your game. See AddToGroup, IsInGroup and RemoveFromGroup. You can then retrieve all nodes in these groups, iterate them and even call methods on groups via the methods on SceneTree.
Networking with nodes: After connecting to a server (or making one, see ENetMultiplayerPeer), it is possible to use the built-in RPC (remote procedure call) system to communicate over the network. By calling Rpc with a method name, it will be called locally and in all connected peers (peers = clients and the server that accepts connections). To identify which node receives the RPC call, Godot will use its node path (make sure node names are the same on all peers). Also, take a look at the high-level networking tutorial and corresponding demos.
Note: The script property is part of the Object class, not Node. It isn't exposed like most properties but does have a setter and getter (see Object.SetScript and Object.GetScript).
Index ¶
- Constants
- func GetOrphanNodeIds() []int
- func PrintOrphanNodes()
- type Advanced
- type Any
- type AutoTranslateMode
- type DuplicateFlags
- type Expanded
- type Extension
- type ID
- type Implementation
- type Instance
- func (self Instance) AddChild(node Instance)
- func (self Instance) AddSibling(sibling Instance)
- func (self Instance) AddToGroup(group string)
- func (self Instance) AsNode() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) Atr(message string) string
- func (self Instance) AtrN(message string, plural_message string, n int) string
- func (self Instance) AutoTranslateMode() AutoTranslateMode
- func (self Instance) BindToTween(peer Tween.Instance) Tween.Instance
- func (self Instance) CallDeferredThreadGroup(method string, args ...any) any
- func (self Instance) CallThreadSafe(method string, args ...any) any
- func (self Instance) CanAutoTranslate() bool
- func (self Instance) CanProcess() bool
- func (self Instance) CreateTween() Tween.Instance
- func (self Instance) Duplicate() Instance
- func (self Instance) EditorDescription() string
- func (self Instance) FindChild(pattern string) Instance
- func (self Instance) FindChildren(pattern string) []Instance
- func (self Instance) FindParent(pattern string) Instance
- func (self Instance) GetAccessibilityElement() RID.AccessibilityElement
- func (self Instance) GetChild(idx int) Instance
- func (self Instance) GetChildCount() int
- func (self Instance) GetChildren() []Instance
- func (self Instance) GetGroups() []string
- func (self Instance) GetIndex() int
- func (self Instance) GetMultiplayerAuthority() int
- func (self Instance) GetNode(path string) Instance
- func (self Instance) GetNodeAndResource(path string) (Instance, Resource.Instance, string)
- func (self Instance) GetNodeOrNull(path string) Instance
- func (self Instance) GetNodeRpcConfig() any
- func (self Instance) GetParent() Instance
- func (self Instance) GetPath() string
- func (self Instance) GetPathTo(node Instance) string
- func (self Instance) GetPhysicsProcessDeltaTime() Float.X
- func (self Instance) GetProcessDeltaTime() Float.X
- func (self Instance) GetSceneInstanceLoadPlaceholder() bool
- func (self Instance) GetTreeString() string
- func (self Instance) GetTreeStringPretty() string
- func (self Instance) HasNode(path string) bool
- func (self Instance) HasNodeAndResource(path string) bool
- func (self Instance) ID() ID
- func (self Instance) IsAncestorOf(node Instance) bool
- func (self Instance) IsDisplayedFolded() bool
- func (self Instance) IsEditableInstance(node Instance) bool
- func (self Instance) IsGreaterThan(node Instance) bool
- func (self Instance) IsInGroup(group string) bool
- func (self Instance) IsInsideTree() bool
- func (self Instance) IsMultiplayerAuthority() bool
- func (self Instance) IsNodeReady() bool
- func (self Instance) IsPartOfEditedScene() bool
- func (self Instance) IsPhysicsInterpolated() bool
- func (self Instance) IsPhysicsInterpolatedAndEnabled() bool
- func (self Instance) IsPhysicsProcessing() bool
- func (self Instance) IsPhysicsProcessingInternal() bool
- func (self Instance) IsProcessing() bool
- func (self Instance) IsProcessingInput() bool
- func (self Instance) IsProcessingInternal() bool
- func (self Instance) IsProcessingShortcutInput() bool
- func (self Instance) IsProcessingUnhandledInput() bool
- func (self Instance) IsProcessingUnhandledKeyInput() bool
- func (self Instance) IsQueuedForDeletion() bool
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) MoveChild(child_node Instance, to_index int)
- func (self Instance) Multiplayer() MultiplayerAPI.Instance
- func (self Instance) Name() string
- func (self Instance) NotifyDeferredThreadGroup(what int)
- func (self Instance) NotifyThreadSafe(what int)
- func (self Instance) OnChildEnteredTree(cb func(node Instance), flags ...Signal.Flags)
- func (self Instance) OnChildExitingTree(cb func(node Instance), flags ...Signal.Flags)
- func (self Instance) OnChildOrderChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnEditorDescriptionChanged(cb func(node Instance), flags ...Signal.Flags)
- func (self Instance) OnEditorStateChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnReady(cb func(), flags ...Signal.Flags)
- func (self Instance) OnRenamed(cb func(), flags ...Signal.Flags)
- func (self Instance) OnReplacingBy(cb func(node Instance), flags ...Signal.Flags)
- func (self Instance) OnTreeEntered(cb func(), flags ...Signal.Flags)
- func (self Instance) OnTreeExited(cb func(), flags ...Signal.Flags)
- func (self Instance) OnTreeExiting(cb func(), flags ...Signal.Flags)
- func (self Instance) Owner() Instance
- func (self Instance) PhysicsInterpolationMode() PhysicsInterpolationMode
- func (self Instance) PrintTree()
- func (self Instance) PrintTreePretty()
- func (self Instance) ProcessMode() ProcessMode
- func (self Instance) ProcessPhysicsPriority() int
- func (self Instance) ProcessPriority() int
- func (self Instance) ProcessThreadGroup() ProcessThreadGroup
- func (self Instance) ProcessThreadGroupOrder() int
- func (self Instance) ProcessThreadMessages() ProcessThreadMessages
- func (self Instance) PropagateCall(method string)
- func (self Instance) PropagateNotification(what int)
- func (self Instance) QueueAccessibilityUpdate()
- func (self Instance) QueueFree()
- func (self Instance) RemoveChild(node Instance)
- func (self Instance) RemoveFromGroup(group string)
- func (self Instance) Reparent(new_parent Instance)
- func (self Instance) ReplaceBy(node Instance)
- func (self Instance) RequestReady()
- func (self Instance) ResetPhysicsInterpolation()
- func (self Instance) Rpc(method string, args ...any) error
- func (self Instance) RpcConfig(method string, config any)
- func (self Instance) RpcId(peer_id int, method string, args ...any) error
- func (self Instance) SceneFilePath() string
- func (self Instance) SetAutoTranslateMode(value AutoTranslateMode)
- func (self Instance) SetDeferredThreadGroup(property string, value any)
- func (self Instance) SetDisplayFolded(fold bool)
- func (self Instance) SetEditableInstance(node Instance, is_editable bool)
- func (self Instance) SetEditorDescription(value string)
- func (self Instance) SetMultiplayerAuthority(id int)
- func (self Instance) SetName(value string)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOwner(value Instance)
- func (self Instance) SetPhysicsInterpolationMode(value PhysicsInterpolationMode)
- func (self Instance) SetPhysicsProcess(enable bool)
- func (self Instance) SetPhysicsProcessInternal(enable bool)
- func (self Instance) SetProcess(enable bool)
- func (self Instance) SetProcessInput(enable bool)
- func (self Instance) SetProcessInternal(enable bool)
- func (self Instance) SetProcessMode(value ProcessMode)
- func (self Instance) SetProcessPhysicsPriority(value int)
- func (self Instance) SetProcessPriority(value int)
- func (self Instance) SetProcessShortcutInput(enable bool)
- func (self Instance) SetProcessThreadGroup(value ProcessThreadGroup)
- func (self Instance) SetProcessThreadGroupOrder(value int)
- func (self Instance) SetProcessThreadMessages(value ProcessThreadMessages)
- func (self Instance) SetProcessUnhandledInput(enable bool)
- func (self Instance) SetProcessUnhandledKeyInput(enable bool)
- func (self Instance) SetSceneFilePath(value string)
- func (self Instance) SetSceneInstanceLoadPlaceholder(load_placeholder bool)
- func (self Instance) SetThreadSafe(property string, value any)
- func (self Instance) SetTranslationDomainInherited()
- func (self Instance) SetUniqueNameInOwner(value bool)
- func (self Instance) UniqueNameInOwner() bool
- func (self Instance) UpdateConfigurationWarnings()
- func (self Instance) Virtual(name string) reflect.Value
- type Interface
- type InternalMode
- type MoreArgs
- func (self MoreArgs) AddChild(node Instance, force_readable_name bool, internal_ InternalMode)
- func (self MoreArgs) AddSibling(sibling Instance, force_readable_name bool)
- func (self MoreArgs) AddToGroup(group string, persistent bool)
- func (self MoreArgs) Atr(message string, context string) string
- func (self MoreArgs) AtrN(message string, plural_message string, n int, context string) string
- func (self MoreArgs) Duplicate(flags int) Instance
- func (self MoreArgs) FindChild(pattern string, recursive bool, owned bool) Instance
- func (self MoreArgs) FindChildren(pattern string, atype string, recursive bool, owned bool) []Instance
- func (self MoreArgs) GetChild(idx int, include_internal bool) Instance
- func (self MoreArgs) GetChildCount(include_internal bool) int
- func (self MoreArgs) GetChildren(include_internal bool) []Instance
- func (self MoreArgs) GetIndex(include_internal bool) int
- func (self MoreArgs) GetPathTo(node Instance, use_unique_path bool) string
- func (self MoreArgs) PropagateCall(method string, args []any, parent_first bool)
- func (self MoreArgs) Reparent(new_parent Instance, keep_global_transform bool)
- func (self MoreArgs) ReplaceBy(node Instance, keep_groups bool)
- func (self MoreArgs) SetMultiplayerAuthority(id int, recursive bool)
- type PhysicsInterpolationMode
- type ProcessMode
- type ProcessThreadGroup
- type ProcessThreadMessages
Constants ¶
const NotificationAccessibilityInvalidate Object.Notification = 3001 //gd:Node.NOTIFICATION_ACCESSIBILITY_INVALIDATE
const NotificationAccessibilityUpdate Object.Notification = 3000 //gd:Node.NOTIFICATION_ACCESSIBILITY_UPDATE
const NotificationApplicationFocusIn Object.Notification = 2016 //gd:Node.NOTIFICATION_APPLICATION_FOCUS_IN
const NotificationApplicationFocusOut Object.Notification = 2017 //gd:Node.NOTIFICATION_APPLICATION_FOCUS_OUT
const NotificationApplicationPaused Object.Notification = 2015 //gd:Node.NOTIFICATION_APPLICATION_PAUSED
const NotificationApplicationResumed Object.Notification = 2014 //gd:Node.NOTIFICATION_APPLICATION_RESUMED
const NotificationChildOrderChanged Object.Notification = 24 //gd:Node.NOTIFICATION_CHILD_ORDER_CHANGED
const NotificationCrash Object.Notification = 2012 //gd:Node.NOTIFICATION_CRASH
const NotificationDisabled Object.Notification = 28 //gd:Node.NOTIFICATION_DISABLED
const NotificationDragBegin Object.Notification = 21 //gd:Node.NOTIFICATION_DRAG_BEGIN
const NotificationDragEnd Object.Notification = 22 //gd:Node.NOTIFICATION_DRAG_END
const NotificationEditorPostSave Object.Notification = 9002 //gd:Node.NOTIFICATION_EDITOR_POST_SAVE
const NotificationEditorPreSave Object.Notification = 9001 //gd:Node.NOTIFICATION_EDITOR_PRE_SAVE
const NotificationEnabled Object.Notification = 29 //gd:Node.NOTIFICATION_ENABLED
const NotificationEnterTree Object.Notification = 10 //gd:Node.NOTIFICATION_ENTER_TREE
const NotificationExitTree Object.Notification = 11 //gd:Node.NOTIFICATION_EXIT_TREE
const NotificationInternalPhysicsProcess Object.Notification = 26 //gd:Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS
const NotificationInternalProcess Object.Notification = 25 //gd:Node.NOTIFICATION_INTERNAL_PROCESS
const NotificationMovedInParent Object.Notification = 12 //gd:Node.NOTIFICATION_MOVED_IN_PARENT
const NotificationOsImeUpdate Object.Notification = 2013 //gd:Node.NOTIFICATION_OS_IME_UPDATE
const NotificationOsMemoryWarning Object.Notification = 2009 //gd:Node.NOTIFICATION_OS_MEMORY_WARNING
const NotificationParented Object.Notification = 18 //gd:Node.NOTIFICATION_PARENTED
const NotificationPathRenamed Object.Notification = 23 //gd:Node.NOTIFICATION_PATH_RENAMED
const NotificationPaused Object.Notification = 14 //gd:Node.NOTIFICATION_PAUSED
const NotificationPhysicsProcess Object.Notification = 16 //gd:Node.NOTIFICATION_PHYSICS_PROCESS
const NotificationPostEnterTree Object.Notification = 27 //gd:Node.NOTIFICATION_POST_ENTER_TREE
const NotificationProcess Object.Notification = 17 //gd:Node.NOTIFICATION_PROCESS
const NotificationReady Object.Notification = 13 //gd:Node.NOTIFICATION_READY
const NotificationResetPhysicsInterpolation Object.Notification = 2001 //gd:Node.NOTIFICATION_RESET_PHYSICS_INTERPOLATION
const NotificationSceneInstantiated Object.Notification = 20 //gd:Node.NOTIFICATION_SCENE_INSTANTIATED
const NotificationTextServerChanged Object.Notification = 2018 //gd:Node.NOTIFICATION_TEXT_SERVER_CHANGED
const NotificationTranslationChanged Object.Notification = 2010 //gd:Node.NOTIFICATION_TRANSLATION_CHANGED
const NotificationUnparented Object.Notification = 19 //gd:Node.NOTIFICATION_UNPARENTED
const NotificationUnpaused Object.Notification = 15 //gd:Node.NOTIFICATION_UNPAUSED
const NotificationVpMouseEnter Object.Notification = 1010 //gd:Node.NOTIFICATION_VP_MOUSE_ENTER
const NotificationVpMouseExit Object.Notification = 1011 //gd:Node.NOTIFICATION_VP_MOUSE_EXIT
const NotificationWmAbout Object.Notification = 2011 //gd:Node.NOTIFICATION_WM_ABOUT
const NotificationWmCloseRequest Object.Notification = 1006 //gd:Node.NOTIFICATION_WM_CLOSE_REQUEST
const NotificationWmDpiChange Object.Notification = 1009 //gd:Node.NOTIFICATION_WM_DPI_CHANGE
const NotificationWmGoBackRequest Object.Notification = 1007 //gd:Node.NOTIFICATION_WM_GO_BACK_REQUEST
const NotificationWmMouseEnter Object.Notification = 1002 //gd:Node.NOTIFICATION_WM_MOUSE_ENTER
const NotificationWmMouseExit Object.Notification = 1003 //gd:Node.NOTIFICATION_WM_MOUSE_EXIT
const NotificationWmPositionChanged Object.Notification = 1012 //gd:Node.NOTIFICATION_WM_POSITION_CHANGED
const NotificationWmSizeChanged Object.Notification = 1008 //gd:Node.NOTIFICATION_WM_SIZE_CHANGED
const NotificationWmWindowFocusIn Object.Notification = 1004 //gd:Node.NOTIFICATION_WM_WINDOW_FOCUS_IN
const NotificationWmWindowFocusOut Object.Notification = 1005 //gd:Node.NOTIFICATION_WM_WINDOW_FOCUS_OUT
Variables ¶
This section is empty.
Functions ¶
func GetOrphanNodeIds ¶
func GetOrphanNodeIds() []int
Returns object IDs of all orphan nodes (nodes outside the SceneTree). Used for debugging.
Note: GetOrphanNodeIds only works in debug builds. When called in a project exported in release mode, GetOrphanNodeIds will return an empty array.
func PrintOrphanNodes ¶
func PrintOrphanNodes()
Prints all orphan nodes (nodes outside the SceneTree). Useful for debugging.
Note: This method only works in debug builds. Does nothing in a project exported in release mode.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type AutoTranslateMode ¶
type AutoTranslateMode int //gd:Node.AutoTranslateMode
const ( // Inherits [AutoTranslateMode] from the node's parent. This is the default for any newly created node. // // [AutoTranslateMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.AutoTranslateMode AutoTranslateModeInherit AutoTranslateMode = 0 // Always automatically translate. This is the inverse of [AutoTranslateModeDisabled], and the default for the root node. AutoTranslateModeAlways AutoTranslateMode = 1 // Never automatically translate. This is the inverse of [AutoTranslateModeAlways]. // // String parsing for POT generation will be skipped for this node and children that are set to [AutoTranslateModeInherit]. AutoTranslateModeDisabled AutoTranslateMode = 2 )
type DuplicateFlags ¶
type DuplicateFlags int //gd:Node.DuplicateFlags
const ( // Duplicate the node's signal connections that are connected with the [Object.ConnectPersist] flag. DuplicateSignals DuplicateFlags = 1 // Duplicate the node's groups. DuplicateGroups DuplicateFlags = 2 // Duplicate the node's script (also overriding the duplicated children's scripts, if combined with [DuplicateUseInstantiation]). DuplicateScripts DuplicateFlags = 4 // Duplicate using [PackedScene.Instantiate]. If the node comes from a scene saved on disk, reuses [PackedScene.Instantiate] as the base for the duplicated node and its children. // // [PackedScene.Instantiate]: https://pkg.go.dev/graphics.gd/classdb/PackedScene#Instance.Instantiate DuplicateUseInstantiation DuplicateFlags = 8 )
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func ResourceLocalScene ¶
If [member resource_local_to_scene] is set to [code]true[/code] and the resource has been loaded from a [PackedScene] instantiation, returns the root [Node] of the scene where this resource is used. Otherwise, returns [code]null[/code].
func (Instance) AddChild ¶
Adds a child 'node'. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
If 'force_readable_name' is true, improves the readability of the added 'node'. If not named, the 'node' is renamed to its type, and if it shares Name with a sibling, a number is suffixed more appropriately. This operation is very slow. As such, it is recommended leaving this to false, which assigns a dummy name featuring @ in both situations.
If 'internal' is different than InternalModeDisabled, the child will be added as internal node. These nodes are ignored by methods like GetChildren, unless their parameter include_internal is true. It also prevents these nodes being duplicated with their parent. The intended usage is to hide the internal nodes from the user, so the user won't accidentally delete or modify them. Used by some GUI nodes, e.g. ColorPicker.
Note: If 'node' already has a parent, this method will fail. Use RemoveChild first to remove 'node' from its current parent. For example:
var childNode = node.GetChild(0) if childNode.GetParent() != Node.Nil { childNode.GetParent().RemoveChild(childNode) } node.AddChild(childNode)
If you need the child node to be added below a specific node in the list of children, use AddSibling instead of this method.
Note: If you want a child to be persisted to a PackedScene, you must set Owner in addition to calling AddChild. This is typically relevant for tool scripts and editor plugins. If AddChild is called without setting Owner, the newly added Node will not be visible in the scene tree, though it will be visible in the 2D/3D view.
func (Instance) AddSibling ¶
Adds a 'sibling' node to this node's parent, and moves the added sibling right below this node.
If 'force_readable_name' is true, improves the readability of the added 'sibling'. If not named, the 'sibling' is renamed to its type, and if it shares Name with a sibling, a number is suffixed more appropriately. This operation is very slow. As such, it is recommended leaving this to false, which assigns a dummy name featuring @ in both situations.
Use AddChild instead of this method if you don't need the child node to be added below a specific node in the list of children.
Note: If this node is internal, the added sibling will be internal too (see AddChild's internal parameter).
func (Instance) AddToGroup ¶
Adds the node to the 'group'. Groups can be helpful to organize a subset of nodes, for example "enemies" or "collectables". See notes in the description, and the group methods in SceneTree.
If 'persistent' is true, the group will be stored when saved inside a PackedScene. All groups created and displayed in the Node dock are persistent.
Note: To improve performance, the order of group names is not guaranteed and may vary between project runs. Therefore, do not rely on the group order.
Note: SceneTree's group methods will not work on this node if not inside the tree (see IsInsideTree).
func (Instance) Atr ¶
Translates a 'message', using the translation catalogs configured in the Project Settings. Further 'context' can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
This method works the same as Object.Tr, with the addition of respecting the AutoTranslateMode state.
If Object.CanTranslateMessages is false, or no translation is available, this method returns the 'message' without changes. See Object.SetMessageTranslation.
For detailed examples, see Internationalizing games.
func (Instance) AtrN ¶
Translates a 'message' or 'plural_message', using the translation catalogs configured in the Project Settings. Further 'context' can be specified to help with the translation.
This method works the same as Object.TrN, with the addition of respecting the AutoTranslateMode state.
If Object.CanTranslateMessages is false, or no translation is available, this method returns 'message' or 'plural_message', without changes. See Object.SetMessageTranslation.
The 'n' is the number, or amount, of the message's subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and Float.X numbers may not properly apply to some countable subjects. It's recommended to handle these cases with Atr.
func (Instance) AutoTranslateMode ¶
func (self Instance) AutoTranslateMode() AutoTranslateMode
Defines if any text should automatically change to its translated version depending on the current locale (for nodes such as Label, RichTextLabel, Window, etc.). Also decides if the node's strings should be parsed for POT generation.
Note: For the root node, auto translate mode can also be set via ProjectSettings "internationalization/rendering/root_node_auto_translate".
func (Instance) BindToTween ¶
Binds this [Tween] with the given [param node]. [Tween]s are processed directly by the [SceneTree], so they run independently of the animated nodes. When you bind a [Node] with the [Tween], the [Tween] will halt the animation when the object is not inside tree and the [Tween] will be automatically killed when the bound object is freed. Also [constant TWEEN_PAUSE_BOUND] will make the pausing behavior dependent on the bound node. For a shorter way to create and bind a [Tween], you can use [method Node.create_tween].
func (Instance) CallDeferredThreadGroup ¶
This function is similar to Object.CallDeferred except that the call will take place when the node thread group is processed. If the node thread group processes in sub-threads, then the call will be done on that thread, right before NotificationProcess or NotificationPhysicsProcess, the Process or PhysicsProcess or their internal versions are called.
func (Instance) CallThreadSafe ¶
This function ensures that the calling of this function will succeed, no matter whether it's being done from a thread or not. If called from a thread that is not allowed to call the function, the call will become deferred. Otherwise, the call will go through directly.
func (Instance) CanAutoTranslate ¶
Returns true if this node can automatically translate messages depending on the current locale. See AutoTranslateMode, Atr, and AtrN.
func (Instance) CanProcess ¶
Returns true if the node can receive processing notifications and input callbacks (NotificationProcess, Input, etc.) from the SceneTree and Viewport. The returned value depends on ProcessMode:
- If set to ProcessModePausable, returns true when the game is processing, i.e. SceneTree.Paused is false;
- If set to ProcessModeWhenPaused, returns true when the game is paused, i.e. SceneTree.Paused is true;
- If set to ProcessModeAlways, always returns true;
- If set to ProcessModeDisabled, always returns false;
- If set to ProcessModeInherit, use the parent node's ProcessMode to determine the result.
If the node is not inside the tree, returns false no matter the value of ProcessMode.
func (Instance) CreateTween ¶
Creates a new Tween and binds it to this node.
This is the equivalent of doing:
node.BindToTween(SceneTree.Get(node).CreateTween())
The Tween will start automatically on the next process frame or physics frame (depending on [Tween.TweenProcessMode]). See Tween.BindNode for more info on Tweens bound to nodes.
Note: The method can still be used when the node is not inside SceneTree. It can fail in an unlikely case of using a custom MainLoop.
func (Instance) Duplicate ¶
Duplicates the node, returning a new node with all of its properties, signals, groups, and children copied from the original. The behavior can be tweaked through the 'flags' (see DuplicateFlags). Internal nodes are not duplicated.
Note: For nodes with a Script attached, if Object.Init has been defined with required parameters, the duplicated node will not have a Script.
func (Instance) EditorDescription ¶
An optional description to the node. It will be displayed as a tooltip when hovering over the node in the editor's Scene dock.
func (Instance) FindChild ¶
Finds the first descendant of this node whose Name matches 'pattern', returning null if no match is found. The matching is done against node names, not their paths, through String.Match. As such, it is case-sensitive, "*" matches zero or more characters, and "?" matches any single character.
If 'recursive' is false, only this node's direct children are checked. Nodes are checked in tree order, so this node's first direct child is checked first, then its own direct children, etc., before moving to the second direct child, and so on. Internal children are also included in the search (see internal parameter in AddChild).
If 'owned' is true, only descendants with a valid Owner node are checked.
Note: This method can be very slow. Consider storing a reference to the found node in a variable. Alternatively, use GetNode with unique names (see UniqueNameInOwner).
Note: To find all descendant nodes matching a pattern or a class type, see FindChildren.
func (Instance) FindChildren ¶
Finds all descendants of this node whose names match 'pattern', returning an empty slice if no match is found. The matching is done against node names, not their paths, through String.Match. As such, it is case-sensitive, "*" matches zero or more characters, and "?" matches any single character.
If 'type' is not empty, only ancestors inheriting from 'type' are included (see Object.IsClass).
If 'recursive' is false, only this node's direct children are checked. Nodes are checked in tree order, so this node's first direct child is checked first, then its own direct children, etc., before moving to the second direct child, and so on. Internal children are also included in the search (see internal parameter in AddChild).
If 'owned' is true, only descendants with a valid Owner node are checked.
Note: This method can be very slow. Consider storing references to the found nodes in a variable.
Note: To find a single descendant node matching a pattern, see FindChild.
func (Instance) FindParent ¶
Finds the first ancestor of this node whose Name matches 'pattern', returning null if no match is found. The matching is done through String.Match. As such, it is case-sensitive, "*" matches zero or more characters, and "?" matches any single character. See also FindChild and FindChildren.
Note: As this method walks upwards in the scene tree, it can be slow in large, deeply nested nodes. Consider storing a reference to the found node in a variable. Alternatively, use GetNode with unique names (see UniqueNameInOwner).
func (Instance) GetAccessibilityElement ¶
func (self Instance) GetAccessibilityElement() RID.AccessibilityElement
Returns main accessibility element RID.
Note: This method should be called only during accessibility information updates (NotificationAccessibilityUpdate).
func (Instance) GetChild ¶
Fetches a child node by its index. Each child node has an index relative to its siblings (see GetIndex). The first child is at index 0. Negative values can also be used to start from the end of the list. This method can be used in combination with GetChildCount to iterate over this node's children. If no child exists at the given index, this method returns null and an error is generated.
If 'include_internal' is false, internal children are ignored (see AddChild's internal parameter).
// Assuming the following are children of this node, in order: // First, Middle, Last. var a = node.GetChild(0).Name() // a is "First" var b = node.GetChild(1).Name() // b is "Middle" b = node.GetChild(2).Name() // b is "Last" var c = node.GetChild(-1).Name() // c is "Last"
Note: To fetch a node by node path, use GetNode.
func (Instance) GetChildCount ¶
Returns the number of children of this node.
If 'include_internal' is false, internal children are not counted (see AddChild's internal parameter).
func (Instance) GetChildren ¶
Returns all children of this node inside an slice.
If 'include_internal' is false, excludes internal children from the returned array (see AddChild's internal parameter).
func (Instance) GetGroups ¶
Returns an slice of group names that the node has been added to.
Note: To improve performance, the order of group names is not guaranteed and may vary between project runs. Therefore, do not rely on the group order.
Note: This method may also return some group names starting with an underscore (_). These are internally used by the engine. To avoid conflicts, do not use custom groups starting with underscores. To exclude internal groups, see the following code snippet:
// Stores the node's non-internal groups only (as a slice of strings). var nonInternalGroups []string for _, group := range node.GetGroups() { if !strings.HasPrefix(group, "_") { nonInternalGroups = append(nonInternalGroups, group) } }
func (Instance) GetIndex ¶
Returns this node's order among its siblings. The first node's index is 0. See also GetChild.
If 'include_internal' is false, returns the index ignoring internal children. The first, non-internal child will have an index of 0 (see AddChild's internal parameter).
func (Instance) GetMultiplayerAuthority ¶
Returns the peer ID of the multiplayer authority for this node. See SetMultiplayerAuthority.
func (Instance) GetNode ¶
Fetches a node. The node path can either be a relative path (from this node), or an absolute path (from the SceneTree.Root) to a node. If 'path' does not point to a valid node, generates an error and returns null. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error.
Note: Fetching by absolute path only works when the node is inside the scene tree (see IsInsideTree).
Example: Assume this method is called from the Character node, inside the following tree:
node.GetNode("Sword") node.GetNode("Backpack/Dagger") node.GetNode("../Swamp/Alligator") node.GetNode("/root/MyGame")
The following calls will return a valid node:
func (Instance) GetNodeAndResource ¶
Fetches a node and its most nested resource as specified by the node path's subname. Returns an slice of size 3 where:
- Element 0 is the Node, or null if not found;
- Element 1 is the subname's last nested Resource, or null if not found;
- Element 2 is the remaining node path, referring to an existing, non-Resource property (see Object.GetIndexed).
Example: Assume that the child's Sprite2D.Texture has been assigned an AtlasTexture:
node, res, path := node.GetNodeAndResource("Area2D/Sprite2D") fmt.Println(node.Name()) // Prints Sprite2D fmt.Println(res) // Prints <null> fmt.Println(path) // Prints ^"" node, res, path = node.GetNodeAndResource("Area2D/Sprite2D:texture:atlas") fmt.Println(node.Name()) // Prints Sprite2D fmt.Println(Object.Instance(res.AsObject()).ClassName()) // Prints AtlasTexture fmt.Println(path) // Prints ^"" node, res, path = node.GetNodeAndResource("Area2D/Sprite2D:texture:atlas:region") fmt.Println(node.Name()) // Prints Sprite2D fmt.Println(Object.Instance(res.AsObject()).ClassName()) // Prints AtlasTexture fmt.Println(path) // Prints ^":region"
func (Instance) GetNodeOrNull ¶
Fetches a node by node path. Similar to GetNode, but does not generate an error if 'path' does not point to a valid node.
func (Instance) GetNodeRpcConfig ¶
Returns a data structure mapping method names to their RPC configuration defined for this node using RpcConfig.
Note: This method only returns the RPC configuration assigned via RpcConfig. See Script.GetRpcConfig to retrieve the RPCs defined by the Script.
func (Instance) GetParent ¶
Returns this node's parent node, or null if the node doesn't have a parent.
func (Instance) GetPath ¶
Returns the node's absolute path, relative to the SceneTree.Root. If the node is not inside the scene tree, this method fails and returns an empty node path.
func (Instance) GetPathTo ¶
Returns the relative node path from this node to the specified 'node'. Both nodes must be in the same SceneTree or scene hierarchy, otherwise this method fails and returns an empty node path.
If 'use_unique_path' is true, returns the shortest path accounting for this node's unique name (see UniqueNameInOwner).
Note: If you get a relative path which starts from a unique node, the path may be longer than a normal relative path, due to the addition of the unique node's name.
func (Instance) GetPhysicsProcessDeltaTime ¶
Returns the time elapsed (in seconds) since the last physics callback. This value is identical to PhysicsProcess's delta parameter, and is often consistent at run-time, unless Engine.PhysicsTicksPerSecond is changed. See also NotificationPhysicsProcess.
Note: The returned value will be larger than expected if running at a framerate lower than Engine.PhysicsTicksPerSecond / Engine.MaxPhysicsStepsPerFrame FPS. This is done to avoid "spiral of death" scenarios where performance would plummet due to an ever-increasing number of physics steps per frame. This behavior affects both Process and PhysicsProcess. As a result, avoid using delta for time measurements in real-world seconds. Use the Time singleton's methods for this purpose instead, such as Time.GetTicksUsec.
func (Instance) GetProcessDeltaTime ¶
Returns the time elapsed (in seconds) since the last process callback. This value is identical to Process's delta parameter, and may vary from frame to frame. See also NotificationProcess.
Note: The returned value will be larger than expected if running at a framerate lower than Engine.PhysicsTicksPerSecond / Engine.MaxPhysicsStepsPerFrame FPS. This is done to avoid "spiral of death" scenarios where performance would plummet due to an ever-increasing number of physics steps per frame. This behavior affects both Process and PhysicsProcess. As a result, avoid using delta for time measurements in real-world seconds. Use the Time singleton's methods for this purpose instead, such as Time.GetTicksUsec.
func (Instance) GetSceneInstanceLoadPlaceholder ¶
Returns true if this node is an instance load placeholder. See InstancePlaceholder and SetSceneInstanceLoadPlaceholder.
func (Instance) GetTreeString ¶
Returns the tree as a string. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the GetNode function. It also can be used in game UI/UX.
May print, for example:
func (Instance) GetTreeStringPretty ¶
Similar to GetTreeString, this returns the tree as a string. This version displays a more graphical representation similar to what is displayed in the Scene Dock. It is useful for inspecting larger trees.
May print, for example:
func (Instance) HasNodeAndResource ¶
Returns true if 'path' points to a valid node and its subnames point to a valid Resource, e.g. Area2D/CollisionShape2D:shape. Properties that are not Resource types (such as nodes or other any types) are not considered. See also GetNodeAndResource.
func (Instance) IsAncestorOf ¶
Returns true if the given 'node' is a direct or indirect child of this node.
func (Instance) IsDisplayedFolded ¶
Returns true if the node is folded (collapsed) in the Scene dock. This method is intended to be used in editor plugins and tools. See also SetDisplayFolded.
func (Instance) IsEditableInstance ¶
Returns true if 'node' has editable children enabled relative to this node. This method is intended to be used in editor plugins and tools. See also SetEditableInstance.
func (Instance) IsGreaterThan ¶
Returns true if the given 'node' occurs later in the scene hierarchy than this node. A node occurring later is usually processed last.
func (Instance) IsInGroup ¶
Returns true if this node has been added to the given 'group'. See AddToGroup and RemoveFromGroup. See also notes in the description, and the SceneTree's group methods.
func (Instance) IsInsideTree ¶
Returns true if this node is currently inside a SceneTree. See also GetTree.
func (Instance) IsMultiplayerAuthority ¶
Returns true if the local system is the multiplayer authority of this node.
func (Instance) IsNodeReady ¶
Returns true if the node is ready, i.e. it's inside scene tree and all its children are initialized.
RequestReady resets it back to false.
func (Instance) IsPartOfEditedScene ¶
Returns true if the node is part of the scene currently opened in the editor.
func (Instance) IsPhysicsInterpolated ¶
Returns true if physics interpolation is enabled for this node (see PhysicsInterpolationMode).
Note: Interpolation will only be active if both the flag is set and physics interpolation is enabled within the SceneTree. This can be tested using IsPhysicsInterpolatedAndEnabled.
func (Instance) IsPhysicsInterpolatedAndEnabled ¶
Returns true if physics interpolation is enabled (see PhysicsInterpolationMode) and enabled in the SceneTree.
This is a convenience version of IsPhysicsInterpolated that also checks whether physics interpolation is enabled globally.
See SceneTree.PhysicsInterpolation and ProjectSettings "physics/common/physics_interpolation".
func (Instance) IsPhysicsProcessing ¶
Returns true if physics processing is enabled (see SetPhysicsProcess).
func (Instance) IsPhysicsProcessingInternal ¶
Returns true if internal physics processing is enabled (see SetPhysicsProcessInternal).
func (Instance) IsProcessing ¶
Returns true if processing is enabled (see SetProcess).
func (Instance) IsProcessingInput ¶
Returns true if the node is processing input (see SetProcessInput).
func (Instance) IsProcessingInternal ¶
Returns true if internal processing is enabled (see SetProcessInternal).
func (Instance) IsProcessingShortcutInput ¶
Returns true if the node is processing shortcuts (see SetProcessShortcutInput).
func (Instance) IsProcessingUnhandledInput ¶
Returns true if the node is processing unhandled input (see SetProcessUnhandledInput).
func (Instance) IsProcessingUnhandledKeyInput ¶
Returns true if the node is processing unhandled key input (see SetProcessUnhandledKeyInput).
func (Instance) IsQueuedForDeletion ¶
IsQueuedForDeletion returns true if the Instance.QueueFree method was called for the object.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) MoveChild ¶
Moves 'child_node' to the given index. A node's index is the order among its siblings. If 'to_index' is negative, the index is counted from the end of the list. See also GetChild and GetIndex.
Note: The processing order of several engine callbacks (Ready, Process, etc.) and notifications sent through PropagateNotification is affected by tree order. CanvasItem nodes are also rendered in tree order. See also ProcessPriority.
func (Instance) Multiplayer ¶
func (self Instance) Multiplayer() MultiplayerAPI.Instance
The MultiplayerAPI instance associated with this node. See SceneTree.GetMultiplayer.
Note: Renaming the node, or moving it in the tree, will not move the MultiplayerAPI to the new path, you will have to update this manually.
func (Instance) Name ¶
The name of the node. This name must be unique among the siblings (other child nodes from the same parent). When set to an existing sibling's name, the node is automatically renamed.
Note: When changing the name, the following characters will be replaced with an underscore: (. : @ / " %). In particular, the @ character is reserved for auto-generated names. See also String.ValidateNodeName.
func (Instance) NotifyDeferredThreadGroup ¶
Similar to CallDeferredThreadGroup, but for notifications.
func (Instance) NotifyThreadSafe ¶
Similar to CallThreadSafe, but for notifications.
func (Instance) OnChildEnteredTree ¶
Emitted when the child 'node' enters the SceneTree, usually because this node entered the tree (see OnTreeEntered), or AddChild has been called.
This signal is emitted after the child node's own NotificationEnterTree and OnTreeEntered.
func (Instance) OnChildExitingTree ¶
Emitted when the child 'node' is about to exit the SceneTree, usually because this node is exiting the tree (see OnTreeExiting), or because the child 'node' is being removed or freed.
When this signal is received, the child 'node' is still accessible inside the tree. This signal is emitted after the child node's own OnTreeExiting and NotificationExitTree.
func (Instance) OnChildOrderChanged ¶
Emitted when the list of children is changed. This happens when child nodes are added, moved or removed.
func (Instance) OnEditorDescriptionChanged ¶
Emitted when the node's editor description field changed.
func (Instance) OnEditorStateChanged ¶
Emitted when an attribute of the node that is relevant to the editor is changed. Only emitted in the editor.
func (Instance) OnRenamed ¶
Emitted when the node's Name is changed, if the node is inside the tree.
func (Instance) OnReplacingBy ¶
Emitted when this node is being replaced by the 'node', see ReplaceBy.
This signal is emitted after 'node' has been added as a child of the original parent node, but before all original child nodes have been reparented to 'node'.
func (Instance) OnTreeEntered ¶
Emitted when the node enters the tree.
This signal is emitted after the related NotificationEnterTree notification.
func (Instance) OnTreeExited ¶
Emitted after the node exits the tree and is no longer active.
This signal is emitted after the related NotificationExitTree notification.
func (Instance) OnTreeExiting ¶
Emitted when the node is just about to exit the tree. The node is still valid. As such, this is the right place for de-initialization (or a "destructor", if you will).
This signal is emitted after the node's ExitTree, and before the related NotificationExitTree.
func (Instance) Owner ¶
The owner of this node. The owner must be an ancestor of this node. When packing the owner node in a PackedScene, all the nodes it owns are also saved with it. See also UniqueNameInOwner.
Note: In the editor, nodes not owned by the scene root are usually not displayed in the Scene dock, and will not be saved. To prevent this, remember to set the owner after calling AddChild.
func (Instance) PhysicsInterpolationMode ¶
func (self Instance) PhysicsInterpolationMode() PhysicsInterpolationMode
The physics interpolation mode to use for this node. Only effective if ProjectSettings "physics/common/physics_interpolation" or SceneTree.PhysicsInterpolation is true.
By default, nodes inherit the physics interpolation mode from their parent. This property can enable or disable physics interpolation individually for each node, regardless of their parents' physics interpolation mode.
Note: Some node types like VehicleWheel3D have physics interpolation disabled by default, as they rely on their own custom solution.
Note: When teleporting a node to a distant position, it's recommended to temporarily disable interpolation with Node.ResetPhysicsInterpolation after moving the node. This avoids creating a visual streak between the old and new positions.
func (Instance) PrintTree ¶
func (self Instance) PrintTree()
Prints the node and its children to the console, recursively. The node does not have to be inside the tree. This method outputs node paths relative to this node, and is good for copy/pasting into GetNode. See also PrintTreePretty.
May print, for example:
func (Instance) PrintTreePretty ¶
func (self Instance) PrintTreePretty()
Prints the node and its children to the console, recursively. The node does not have to be inside the tree. Similar to PrintTree, but the graphical representation looks like what is displayed in the editor's Scene dock. It is useful for inspecting larger trees.
May print, for example:
func (Instance) ProcessMode ¶
func (self Instance) ProcessMode() ProcessMode
The node's processing behavior. To check if the node can process in its current mode, use CanProcess.
func (Instance) ProcessPhysicsPriority ¶
Similar to ProcessPriority but for NotificationPhysicsProcess, PhysicsProcess, or NotificationInternalPhysicsProcess.
func (Instance) ProcessPriority ¶
The node's execution order of the process callbacks (Process, NotificationProcess, and NotificationInternalProcess). Nodes whose priority value is lower call their process callbacks first, regardless of tree order.
func (Instance) ProcessThreadGroup ¶
func (self Instance) ProcessThreadGroup() ProcessThreadGroup
Set the process thread group for this node (basically, whether it receives NotificationProcess, NotificationPhysicsProcess, Process or PhysicsProcess (and the internal versions) on the main thread or in a sub-thread.
By default, the thread group is ProcessThreadGroupInherit, which means that this node belongs to the same thread group as the parent node. The thread groups means that nodes in a specific thread group will process together, separate to other thread groups (depending on ProcessThreadGroupOrder). If the value is set is ProcessThreadGroupSubThread, this thread group will occur on a sub thread (not the main thread), otherwise if set to ProcessThreadGroupMainThread it will process on the main thread. If there is not a parent or grandparent node set to something other than inherit, the node will belong to the default thread group. This default group will process on the main thread and its group order is 0.
During processing in a sub-thread, accessing most functions in nodes outside the thread group is forbidden (and it will result in an error in debug mode). Use Object.CallDeferred, CallThreadSafe, CallDeferredThreadGroup and the likes in order to communicate from the thread groups to the main thread (or to other thread groups).
To better understand process thread groups, the idea is that any node set to any other value than ProcessThreadGroupInherit will include any child (and grandchild) nodes set to inherit into its process thread group. This means that the processing of all the nodes in the group will happen together, at the same time as the node including them.
func (Instance) ProcessThreadGroupOrder ¶
Change the process thread group order. Groups with a lesser order will process before groups with a greater order. This is useful when a large amount of nodes process in sub thread and, afterwards, another group wants to collect their result in the main thread, as an example.
func (Instance) ProcessThreadMessages ¶
func (self Instance) ProcessThreadMessages() ProcessThreadMessages
Set whether the current thread group will process messages (calls to CallDeferredThreadGroup on threads), and whether it wants to receive them during regular process or physics process callbacks.
func (Instance) PropagateCall ¶
Calls the given 'method' name, passing 'args' as arguments, on this node and all of its children, recursively.
If 'parent_first' is true, the method is called on this node first, then on all of its children. If false, the children's methods are called first.
func (Instance) PropagateNotification ¶
Calls Object.Notification with 'what' on this node and all of its children, recursively.
func (Instance) QueueAccessibilityUpdate ¶
func (self Instance) QueueAccessibilityUpdate()
Queues an accessibility information update for this node.
func (Instance) QueueFree ¶
func (self Instance) QueueFree()
Queues this node to be deleted at the end of the current frame. When deleted, all of its children are deleted as well, and all references to the node and its children become invalid.
Unlike with Object.Free, the node is not deleted instantly, and it can still be accessed before deletion. It is also safe to call QueueFree multiple times. Use Object.IsQueuedForDeletion to check if the node will be deleted at the end of the frame.
Note: The node will only be freed after all other deferred calls are finished. Using this method is not always the same as calling Object.Free through Object.CallDeferred.
func (Instance) RemoveChild ¶
Removes a child 'node'. The 'node', along with its children, are not deleted. To delete a node, see QueueFree.
Note: When this node is inside the tree, this method sets the Owner of the removed 'node' (or its descendants) to null, if their Owner is no longer an ancestor (see IsAncestorOf).
func (Instance) RemoveFromGroup ¶
Removes the node from the given 'group'. Does nothing if the node is not in the 'group'. See also notes in the description, and the SceneTree's group methods.
func (Instance) Reparent ¶
Changes the parent of this Node to the 'new_parent'. The node needs to already have a parent. The node's Owner is preserved if its owner is still reachable from the new location (i.e., the node is still a descendant of the new parent after the operation).
If 'keep_global_transform' is true, the node's global transform will be preserved if supported. Node2D, Node3D and Control support this argument (but Control keeps only position).
func (Instance) ReplaceBy ¶
Replaces this node by the given 'node'. All children of this node are moved to 'node'.
If 'keep_groups' is true, the 'node' is added to the same groups that the replaced node is in (see AddToGroup).
Warning: The replaced node is removed from the tree, but it is not deleted. To prevent memory leaks, store a reference to the node in a variable, or use Object.Free.
func (Instance) RequestReady ¶
func (self Instance) RequestReady()
Requests Ready to be called again the next time the node enters the tree. Does not immediately call Ready.
Note: This method only affects the current node. If the node's children also need to request ready, this method needs to be called for each one of them. When the node and its children enter the tree again, the order of Ready callbacks will be the same as normal.
func (Instance) ResetPhysicsInterpolation ¶
func (self Instance) ResetPhysicsInterpolation()
When physics interpolation is active, moving a node to a radically different transform (such as placement within a level) can result in a visible glitch as the object is rendered moving from the old to new position over the physics tick.
That glitch can be prevented by calling this method, which temporarily disables interpolation until the physics tick is complete.
The notification NotificationResetPhysicsInterpolation will be received by the node and all children recursively.
Note: This function should be called after moving the node, rather than before.
func (Instance) Rpc ¶
Sends a remote procedure call request for the given 'method' to peers on the network (and locally), sending additional arguments to the method called by the RPC. The call request will only be received by nodes with the same node path, including the exact same Name. Behavior depends on the RPC configuration for the given 'method' (see RpcConfig and ). By default, methods are not exposed to RPCs.
May return [constant OK] if the call is successful, [constant ERR_INVALID_PARAMETER] if the arguments passed in the [param method] do not match, [constant ERR_UNCONFIGURED] if the node's [member multiplayer] cannot be fetched (such as when the node is not inside the tree), [constant ERR_CONNECTION_ERROR] if [member multiplayer]'s connection is not available.
[b]Note:[/b] You can only safely use RPCs on clients after you received the [signal MultiplayerAPI.connected_to_server] signal from the MultiplayerAPI. You also need to keep track of the connection state, either by the MultiplayerAPI signals like [signal MultiplayerAPI.server_disconnected] or by checking ([code]get_multiplayer().peer.get_connection_status() == CONNECTION_CONNECTED[/code]).). By default, methods are not exposed to RPCs.
May return [Ok] if the call is successful, [ErrInvalidParameter] if the arguments passed in the 'method' do not match, [ErrUnconfigured] if the node's Multiplayer cannot be fetched (such as when the node is not inside the tree), [ErrConnectionError] if Multiplayer's connection is not available.
Note: You can only safely use RPCs on clients after you received the OnMultiplayerapi.ConnectedToServer signal from the MultiplayerAPI. You also need to keep track of the connection state, either by the MultiplayerAPI signals like OnMultiplayerapi.ServerDisconnected or by checking (get_multiplayer().peer.get_connection_status() == CONNECTION_CONNECTED).
func (Instance) RpcConfig ¶
Changes the RPC configuration for the given 'method'. 'config' should either be null to disable the feature (as by default), or a data structure containing the following entries:
- rpc_mode: see [MultiplayerAPI.RPCMode];
- transfer_mode: see [MultiplayerPeer.TransferMode];
- call_local: if true, the method will also be called locally;
- channel: an int representing the channel to send the RPC on.
Note: In GDScript, this method corresponds to the annotation, with various parameters passed ([code]@rpc(any)[/code], [code]@rpc(authority)[/code]...). See also the [url=https://docs.godotengine.org/tutorials/networking/high_level_multiplayer.html]high-level multiplayer[/url] tutorial. annotation, with various parameters passed (@rpc(any), @rpc(authority)...). See also the high-level multiplayer tutorial.
func (Instance) RpcId ¶
Sends a Rpc to a specific peer identified by 'peer_id' (see MultiplayerPeer.SetTargetPeer).
May return [Ok] if the call is successful, [ErrInvalidParameter] if the arguments passed in the 'method' do not match, [ErrUnconfigured] if the node's Multiplayer cannot be fetched (such as when the node is not inside the tree), [ErrConnectionError] if Multiplayer's connection is not available.
func (Instance) SceneFilePath ¶
The original scene's file path, if the node has been instantiated from a PackedScene file. Only scene root nodes contains this.
func (Instance) SetAutoTranslateMode ¶
func (self Instance) SetAutoTranslateMode(value AutoTranslateMode)
SetAutoTranslateMode sets the property returned by [GetAutoTranslateMode].
func (Instance) SetDeferredThreadGroup ¶
Similar to CallDeferredThreadGroup, but for setting properties.
func (Instance) SetDisplayFolded ¶
If set to true, the node appears folded in the Scene dock. As a result, all of its children are hidden. This method is intended to be used in editor plugins and tools, but it also works in release builds. See also IsDisplayedFolded.
func (Instance) SetEditableInstance ¶
Set to true to allow all nodes owned by 'node' to be available, and editable, in the Scene dock, even if their Owner is not the scene root. This method is intended to be used in editor plugins and tools, but it also works in release builds. See also IsEditableInstance.
func (Instance) SetEditorDescription ¶
SetEditorDescription sets the property returned by [GetEditorDescription].
func (Instance) SetMultiplayerAuthority ¶
Sets the node's multiplayer authority to the peer with the given peer 'id'. The multiplayer authority is the peer that has authority over the node on the network. Defaults to peer ID 1 (the server). Useful in conjunction with RpcConfig and the MultiplayerAPI.
If 'recursive' is true, the given peer is recursively set as the authority for all children of this node.
Warning: This does not automatically replicate the new authority to other peers. It is the developer's responsibility to do so. You may replicate the new authority's information using MultiplayerSpawner.SpawnFunction, an RPC, or a MultiplayerSynchronizer. Furthermore, the parent's authority does not propagate to newly added children.
func (Instance) SetPhysicsInterpolationMode ¶
func (self Instance) SetPhysicsInterpolationMode(value PhysicsInterpolationMode)
SetPhysicsInterpolationMode sets the property returned by [GetPhysicsInterpolationMode].
func (Instance) SetPhysicsProcess ¶
If set to true, enables physics (fixed framerate) processing. When a node is being processed, it will receive a NotificationPhysicsProcess at a fixed (usually 60 FPS, see Engine.PhysicsTicksPerSecond to change) interval (and the PhysicsProcess callback will be called if it exists).
Note: If PhysicsProcess is overridden, this will be automatically enabled before Ready is called.
func (Instance) SetPhysicsProcessInternal ¶
If set to true, enables internal physics for this node. Internal physics processing happens in isolation from the normal PhysicsProcess calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting (SetPhysicsProcess).
Warning: Built-in nodes rely on internal processing for their internal logic. Disabling it is unsafe and may lead to unexpected behavior. Use this method if you know what you are doing.
func (Instance) SetProcess ¶
If set to true, enables processing. When a node is being processed, it will receive a NotificationProcess on every drawn frame (and the Process callback will be called if it exists).
Note: If Process is overridden, this will be automatically enabled before Ready is called.
Note: This method only affects the Process callback, i.e. it has no effect on other callbacks like PhysicsProcess. If you want to disable all processing for the node, set ProcessMode to ProcessModeDisabled.
func (Instance) SetProcessInput ¶
If set to true, enables input processing.
Note: If Input is overridden, this will be automatically enabled before Ready is called. Input processing is also already enabled for GUI controls, such as Button and TextEdit.
func (Instance) SetProcessInternal ¶
If set to true, enables internal processing for this node. Internal processing happens in isolation from the normal Process calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting (SetProcess).
Warning: Built-in nodes rely on internal processing for their internal logic. Disabling it is unsafe and may lead to unexpected behavior. Use this method if you know what you are doing.
func (Instance) SetProcessMode ¶
func (self Instance) SetProcessMode(value ProcessMode)
SetProcessMode sets the property returned by [GetProcessMode].
func (Instance) SetProcessPhysicsPriority ¶
SetProcessPhysicsPriority sets the property returned by [GetPhysicsProcessPriority].
func (Instance) SetProcessPriority ¶
SetProcessPriority sets the property returned by [GetProcessPriority].
func (Instance) SetProcessShortcutInput ¶
If set to true, enables shortcut processing for this node.
Note: If ShortcutInput is overridden, this will be automatically enabled before Ready is called.
func (Instance) SetProcessThreadGroup ¶
func (self Instance) SetProcessThreadGroup(value ProcessThreadGroup)
SetProcessThreadGroup sets the property returned by [GetProcessThreadGroup].
func (Instance) SetProcessThreadGroupOrder ¶
SetProcessThreadGroupOrder sets the property returned by [GetProcessThreadGroupOrder].
func (Instance) SetProcessThreadMessages ¶
func (self Instance) SetProcessThreadMessages(value ProcessThreadMessages)
SetProcessThreadMessages sets the property returned by [GetProcessThreadMessages].
func (Instance) SetProcessUnhandledInput ¶
If set to true, enables unhandled input processing. It enables the node to receive all input that was not previously handled (usually by a Control).
Note: If UnhandledInput is overridden, this will be automatically enabled before Ready is called. Unhandled input processing is also already enabled for GUI controls, such as Button and TextEdit.
func (Instance) SetProcessUnhandledKeyInput ¶
If set to true, enables unhandled key input processing.
Note: If UnhandledKeyInput is overridden, this will be automatically enabled before Ready is called.
func (Instance) SetSceneFilePath ¶
SetSceneFilePath sets the property returned by [GetSceneFilePath].
func (Instance) SetSceneInstanceLoadPlaceholder ¶
If set to true, the node becomes an InstancePlaceholder when packed and instantiated from a PackedScene. See also GetSceneInstanceLoadPlaceholder.
func (Instance) SetThreadSafe ¶
Similar to CallThreadSafe, but for setting properties.
func (Instance) SetTranslationDomainInherited ¶
func (self Instance) SetTranslationDomainInherited()
Makes this node inherit the translation domain from its parent node. If this node has no parent, the main translation domain will be used.
This is the default behavior for all nodes. Calling Object.SetTranslationDomain disables this behavior.
func (Instance) SetUniqueNameInOwner ¶
SetUniqueNameInOwner sets the property returned by [IsUniqueNameInOwner].
func (Instance) UniqueNameInOwner ¶
If true, the node can be accessed from any node sharing the same Owner or from the Owner itself, with special %Name syntax in GetNode.
Note: If another node with the same Owner shares the same Name as this node, the other node will no longer be accessible as unique.
func (Instance) UpdateConfigurationWarnings ¶
func (self Instance) UpdateConfigurationWarnings()
Refreshes the warnings displayed for this node in the Scene dock. Use GetConfigurationWarnings to customize the warning messages to display.
type Interface ¶
type Interface interface { // Called on each idle frame, prior to rendering, and after physics ticks have been processed. 'delta' is the time between frames in seconds. // // It is only called if processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with [SetProcess]. // // Processing happens in order of [ProcessPriority], lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal). // // Corresponds to the [NotificationProcess] notification in [Object.Notification]. // // Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan). // // Note: When the engine is struggling and the frame rate is lowered, 'delta' will increase. When 'delta' is increased, it's capped at a maximum of [Engine.TimeScale] * [Engine.MaxPhysicsStepsPerFrame] / [Engine.PhysicsTicksPerSecond]. As a result, accumulated 'delta' may not represent real world time. // // Note: When --fixed-fps is enabled or the engine is running in Movie Maker mode (see [MovieWriter]), process 'delta' will always be the same for every frame, regardless of how much time the frame took to render. // // Note: Frame delta may be post-processed by [OS.DeltaSmoothing] if this is enabled for the project. // // [Engine.MaxPhysicsStepsPerFrame]: https://pkg.go.dev/graphics.gd/classdb/Engine#MaxPhysicsStepsPerFrame // [Engine.PhysicsTicksPerSecond]: https://pkg.go.dev/graphics.gd/classdb/Engine#PhysicsTicksPerSecond // [Engine.TimeScale]: https://pkg.go.dev/graphics.gd/classdb/Engine#TimeScale // [MovieWriter]: https://pkg.go.dev/graphics.gd/classdb/MovieWriter // [OS.DeltaSmoothing]: https://pkg.go.dev/graphics.gd/classdb/OS#DeltaSmoothing // [Object.Notification]: https://pkg.go.dev/graphics.gd/variant/Object#Notification // [ProcessPriority]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.ProcessPriority // [SetProcess]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.SetProcess Process(delta Float.X) // Called once on each physics tick, and allows Nodes to synchronize their logic with physics ticks. 'delta' is the logical time between physics ticks in seconds and is equal to [Engine.TimeScale] / [Engine.PhysicsTicksPerSecond]. // // It is only called if physics processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with [SetPhysicsProcess]. // // Processing happens in order of [ProcessPhysicsPriority], lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal). // // Corresponds to the [NotificationPhysicsProcess] notification in [Object.Notification]. // // Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan). // // Note: Accumulated 'delta' may diverge from real world seconds. // // [Engine.PhysicsTicksPerSecond]: https://pkg.go.dev/graphics.gd/classdb/Engine#PhysicsTicksPerSecond // [Engine.TimeScale]: https://pkg.go.dev/graphics.gd/classdb/Engine#TimeScale // [Object.Notification]: https://pkg.go.dev/graphics.gd/variant/Object#Notification // [ProcessPhysicsPriority]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.ProcessPhysicsPriority // [SetPhysicsProcess]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.SetPhysicsProcess PhysicsProcess(delta Float.X) // Called when the node enters the [SceneTree] (e.g. upon instantiating, scene changing, or after calling [AddChild] in a script). If the node has children, its [EnterTree] callback will be called first, and then that of the children. // // Corresponds to the [NotificationEnterTree] notification in [Object.Notification]. // // [AddChild]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.AddChild // [EnterTree]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Object.Notification]: https://pkg.go.dev/graphics.gd/variant/Object#Notification // [SceneTree]: https://pkg.go.dev/graphics.gd/classdb/SceneTree EnterTree() // Called when the node is about to leave the [SceneTree] (e.g. upon freeing, scene changing, or after calling [RemoveChild] in a script). If the node has children, its [ExitTree] callback will be called last, after all its children have left the tree. // // Corresponds to the [NotificationExitTree] notification in [Object.Notification] and signal [OnTreeExiting]. To get notified when the node has already left the active tree, connect to the [OnTreeExited]. // // [ExitTree]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Object.Notification]: https://pkg.go.dev/graphics.gd/variant/Object#Notification // [OnTreeExited]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.OnTreeExited // [OnTreeExiting]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.OnTreeExiting // [RemoveChild]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.RemoveChild // [SceneTree]: https://pkg.go.dev/graphics.gd/classdb/SceneTree ExitTree() // Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their [Ready] callbacks get triggered first, and the parent node will receive the ready notification afterwards. // // Corresponds to the [NotificationReady] notification in [Object.Notification]. See also the @onready annotation for variables. // // Usually used for initialization. For even earlier initialization, [Object.Init] may be used. See also [EnterTree]. // // Note: This method may be called only once for each node. After removing a node from the scene tree and adding it again, [Ready] will not be called a second time. This can be bypassed by requesting another call with [RequestReady], which may be called anywhere before adding the node again. // // [EnterTree]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Object.Init]: https://pkg.go.dev/graphics.gd/variant/Object#Init // [Object.Notification]: https://pkg.go.dev/graphics.gd/variant/Object#Notification // [Ready]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [RequestReady]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.RequestReady Ready() // The elements in the array returned from this method are displayed as warnings in the Scene dock if the script that overrides it is a tool script. // // Returning an empty array produces no warnings. // // Call [UpdateConfigurationWarnings] when the warnings need to be updated for this node. // // // // @export var energy = 0: // // set(value): // // energy = value // // update_configuration_warnings() // // // // func _get_configuration_warnings(): // // if energy < 0: // // return ["Energy must be 0 or greater."] // // else: // // return [] // // // // [UpdateConfigurationWarnings]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.UpdateConfigurationWarnings GetConfigurationWarnings() []string // The elements in the array returned from this method are displayed as warnings in the Scene dock if the script that overrides it is a tool script, and accessibility warnings are enabled in the editor settings. // // Returning an empty array produces no warnings. GetAccessibilityConfigurationWarnings() []string // Called when there is an input event. The input event propagates up through the node tree until a node consumes it. // // It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [SetProcessInput]. // // To consume the input event and stop it propagating further to other nodes, [Viewport.SetInputAsHandled] can be called. // // For gameplay input, [UnhandledInput] and [UnhandledKeyInput] are usually a better fit as they allow the GUI to intercept the events first. // // Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan). // // [SetProcessInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.SetProcessInput // [UnhandledInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [UnhandledKeyInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Viewport.SetInputAsHandled]: https://pkg.go.dev/graphics.gd/classdb/Viewport#Instance.SetInputAsHandled Input(event InputEvent.Instance) // Called when an [InputEventKey], [InputEventShortcut], or [InputEventJoypadButton] hasn't been consumed by [Input] or any GUI [Control] item. It is called before [UnhandledKeyInput] and [UnhandledInput]. The input event propagates up through the node tree until a node consumes it. // // It is only called if shortcut processing is enabled, which is done automatically if this method is overridden, and can be toggled with [SetProcessShortcutInput]. // // To consume the input event and stop it propagating further to other nodes, [Viewport.SetInputAsHandled] can be called. // // This method can be used to handle shortcuts. For generic GUI events, use [Input] instead. Gameplay events should usually be handled with either [UnhandledInput] or [UnhandledKeyInput]. // // Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan). // // [Control]: https://pkg.go.dev/graphics.gd/classdb/Control // [Input]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [InputEventJoypadButton]: https://pkg.go.dev/graphics.gd/classdb/InputEventJoypadButton // [InputEventKey]: https://pkg.go.dev/graphics.gd/classdb/InputEventKey // [InputEventShortcut]: https://pkg.go.dev/graphics.gd/classdb/InputEventShortcut // [SetProcessShortcutInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.SetProcessShortcutInput // [UnhandledInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [UnhandledKeyInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Viewport.SetInputAsHandled]: https://pkg.go.dev/graphics.gd/classdb/Viewport#Instance.SetInputAsHandled ShortcutInput(event InputEvent.Instance) // Called when an [InputEvent] hasn't been consumed by [Input] or any GUI [Control] item. It is called after [ShortcutInput] and after [UnhandledKeyInput]. The input event propagates up through the node tree until a node consumes it. // // It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [SetProcessUnhandledInput]. // // To consume the input event and stop it propagating further to other nodes, [Viewport.SetInputAsHandled] can be called. // // For gameplay input, this method is usually a better fit than [Input], as GUI events need a higher priority. For keyboard shortcuts, consider using [ShortcutInput] instead, as it is called before this method. Finally, to handle keyboard events, consider using [UnhandledKeyInput] for performance reasons. // // Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan). // // [Control]: https://pkg.go.dev/graphics.gd/classdb/Control // [Input]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [InputEvent]: https://pkg.go.dev/graphics.gd/classdb/InputEvent // [SetProcessUnhandledInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.SetProcessUnhandledInput // [ShortcutInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [UnhandledKeyInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Viewport.SetInputAsHandled]: https://pkg.go.dev/graphics.gd/classdb/Viewport#Instance.SetInputAsHandled UnhandledInput(event InputEvent.Instance) // Called when an [InputEventKey] hasn't been consumed by [Input] or any GUI [Control] item. It is called after [ShortcutInput] but before [UnhandledInput]. The input event propagates up through the node tree until a node consumes it. // // It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [SetProcessUnhandledKeyInput]. // // To consume the input event and stop it propagating further to other nodes, [Viewport.SetInputAsHandled] can be called. // // This method can be used to handle Unicode character input with Alt, Alt + Ctrl, and Alt + Shift modifiers, after shortcuts were handled. // // For gameplay input, this and [UnhandledInput] are usually a better fit than [Input], as GUI events should be handled first. This method also performs better than [UnhandledInput], since unrelated events such as [InputEventMouseMotion] are automatically filtered. For shortcuts, consider using [ShortcutInput] instead. // // Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan). // // [Control]: https://pkg.go.dev/graphics.gd/classdb/Control // [Input]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [InputEventKey]: https://pkg.go.dev/graphics.gd/classdb/InputEventKey // [InputEventMouseMotion]: https://pkg.go.dev/graphics.gd/classdb/InputEventMouseMotion // [SetProcessUnhandledKeyInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.SetProcessUnhandledKeyInput // [ShortcutInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [UnhandledInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Interface // [Viewport.SetInputAsHandled]: https://pkg.go.dev/graphics.gd/classdb/Viewport#Instance.SetInputAsHandled UnhandledKeyInput(event InputEvent.Instance) // Called during accessibility information updates to determine the currently focused sub-element, should return a sub-element RID or the value returned by [GetAccessibilityElement]. // // [GetAccessibilityElement]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.GetAccessibilityElement GetFocusedAccessibilityElement() RID.AccessibilityElement }
type InternalMode ¶
type InternalMode int //gd:Node.InternalMode
const ( // The node will not be internal. InternalModeDisabled InternalMode = 0 // The node will be placed at the beginning of the parent's children, before any non-internal sibling. InternalModeFront InternalMode = 1 // The node will be placed at the end of the parent's children, after any non-internal sibling. InternalModeBack InternalMode = 2 )
type MoreArgs ¶
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) AddChild ¶
func (self MoreArgs) AddChild(node Instance, force_readable_name bool, internal_ InternalMode)
Adds a child 'node'. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
If 'force_readable_name' is true, improves the readability of the added 'node'. If not named, the 'node' is renamed to its type, and if it shares Name with a sibling, a number is suffixed more appropriately. This operation is very slow. As such, it is recommended leaving this to false, which assigns a dummy name featuring @ in both situations.
If 'internal' is different than InternalModeDisabled, the child will be added as internal node. These nodes are ignored by methods like GetChildren, unless their parameter include_internal is true. It also prevents these nodes being duplicated with their parent. The intended usage is to hide the internal nodes from the user, so the user won't accidentally delete or modify them. Used by some GUI nodes, e.g. ColorPicker.
Note: If 'node' already has a parent, this method will fail. Use RemoveChild first to remove 'node' from its current parent. For example:
var childNode = node.GetChild(0) if childNode.GetParent() != Node.Nil { childNode.GetParent().RemoveChild(childNode) } node.AddChild(childNode)
If you need the child node to be added below a specific node in the list of children, use AddSibling instead of this method.
Note: If you want a child to be persisted to a PackedScene, you must set Owner in addition to calling AddChild. This is typically relevant for tool scripts and editor plugins. If AddChild is called without setting Owner, the newly added Node will not be visible in the scene tree, though it will be visible in the 2D/3D view.
func (MoreArgs) AddSibling ¶
Adds a 'sibling' node to this node's parent, and moves the added sibling right below this node.
If 'force_readable_name' is true, improves the readability of the added 'sibling'. If not named, the 'sibling' is renamed to its type, and if it shares Name with a sibling, a number is suffixed more appropriately. This operation is very slow. As such, it is recommended leaving this to false, which assigns a dummy name featuring @ in both situations.
Use AddChild instead of this method if you don't need the child node to be added below a specific node in the list of children.
Note: If this node is internal, the added sibling will be internal too (see AddChild's internal parameter).
func (MoreArgs) AddToGroup ¶
Adds the node to the 'group'. Groups can be helpful to organize a subset of nodes, for example "enemies" or "collectables". See notes in the description, and the group methods in SceneTree.
If 'persistent' is true, the group will be stored when saved inside a PackedScene. All groups created and displayed in the Node dock are persistent.
Note: To improve performance, the order of group names is not guaranteed and may vary between project runs. Therefore, do not rely on the group order.
Note: SceneTree's group methods will not work on this node if not inside the tree (see IsInsideTree).
func (MoreArgs) Atr ¶
Translates a 'message', using the translation catalogs configured in the Project Settings. Further 'context' can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
This method works the same as Object.Tr, with the addition of respecting the AutoTranslateMode state.
If Object.CanTranslateMessages is false, or no translation is available, this method returns the 'message' without changes. See Object.SetMessageTranslation.
For detailed examples, see Internationalizing games.
func (MoreArgs) AtrN ¶
Translates a 'message' or 'plural_message', using the translation catalogs configured in the Project Settings. Further 'context' can be specified to help with the translation.
This method works the same as Object.TrN, with the addition of respecting the AutoTranslateMode state.
If Object.CanTranslateMessages is false, or no translation is available, this method returns 'message' or 'plural_message', without changes. See Object.SetMessageTranslation.
The 'n' is the number, or amount, of the message's subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and Float.X numbers may not properly apply to some countable subjects. It's recommended to handle these cases with Atr.
func (MoreArgs) Duplicate ¶
Duplicates the node, returning a new node with all of its properties, signals, groups, and children copied from the original. The behavior can be tweaked through the 'flags' (see DuplicateFlags). Internal nodes are not duplicated.
Note: For nodes with a Script attached, if Object.Init has been defined with required parameters, the duplicated node will not have a Script.
func (MoreArgs) FindChild ¶
Finds the first descendant of this node whose Name matches 'pattern', returning null if no match is found. The matching is done against node names, not their paths, through String.Match. As such, it is case-sensitive, "*" matches zero or more characters, and "?" matches any single character.
If 'recursive' is false, only this node's direct children are checked. Nodes are checked in tree order, so this node's first direct child is checked first, then its own direct children, etc., before moving to the second direct child, and so on. Internal children are also included in the search (see internal parameter in AddChild).
If 'owned' is true, only descendants with a valid Owner node are checked.
Note: This method can be very slow. Consider storing a reference to the found node in a variable. Alternatively, use GetNode with unique names (see UniqueNameInOwner).
Note: To find all descendant nodes matching a pattern or a class type, see FindChildren.
func (MoreArgs) FindChildren ¶
func (self MoreArgs) FindChildren(pattern string, atype string, recursive bool, owned bool) []Instance
Finds all descendants of this node whose names match 'pattern', returning an empty slice if no match is found. The matching is done against node names, not their paths, through String.Match. As such, it is case-sensitive, "*" matches zero or more characters, and "?" matches any single character.
If 'type' is not empty, only ancestors inheriting from 'type' are included (see Object.IsClass).
If 'recursive' is false, only this node's direct children are checked. Nodes are checked in tree order, so this node's first direct child is checked first, then its own direct children, etc., before moving to the second direct child, and so on. Internal children are also included in the search (see internal parameter in AddChild).
If 'owned' is true, only descendants with a valid Owner node are checked.
Note: This method can be very slow. Consider storing references to the found nodes in a variable.
Note: To find a single descendant node matching a pattern, see FindChild.
func (MoreArgs) GetChild ¶
Fetches a child node by its index. Each child node has an index relative to its siblings (see GetIndex). The first child is at index 0. Negative values can also be used to start from the end of the list. This method can be used in combination with GetChildCount to iterate over this node's children. If no child exists at the given index, this method returns null and an error is generated.
If 'include_internal' is false, internal children are ignored (see AddChild's internal parameter).
// Assuming the following are children of this node, in order: // First, Middle, Last. var a = node.GetChild(0).Name() // a is "First" var b = node.GetChild(1).Name() // b is "Middle" b = node.GetChild(2).Name() // b is "Last" var c = node.GetChild(-1).Name() // c is "Last"
Note: To fetch a node by node path, use GetNode.
func (MoreArgs) GetChildCount ¶
Returns the number of children of this node.
If 'include_internal' is false, internal children are not counted (see AddChild's internal parameter).
func (MoreArgs) GetChildren ¶
Returns all children of this node inside an slice.
If 'include_internal' is false, excludes internal children from the returned array (see AddChild's internal parameter).
func (MoreArgs) GetIndex ¶
Returns this node's order among its siblings. The first node's index is 0. See also GetChild.
If 'include_internal' is false, returns the index ignoring internal children. The first, non-internal child will have an index of 0 (see AddChild's internal parameter).
func (MoreArgs) GetPathTo ¶
Returns the relative node path from this node to the specified 'node'. Both nodes must be in the same SceneTree or scene hierarchy, otherwise this method fails and returns an empty node path.
If 'use_unique_path' is true, returns the shortest path accounting for this node's unique name (see UniqueNameInOwner).
Note: If you get a relative path which starts from a unique node, the path may be longer than a normal relative path, due to the addition of the unique node's name.
func (MoreArgs) PropagateCall ¶
Calls the given 'method' name, passing 'args' as arguments, on this node and all of its children, recursively.
If 'parent_first' is true, the method is called on this node first, then on all of its children. If false, the children's methods are called first.
func (MoreArgs) Reparent ¶
Changes the parent of this Node to the 'new_parent'. The node needs to already have a parent. The node's Owner is preserved if its owner is still reachable from the new location (i.e., the node is still a descendant of the new parent after the operation).
If 'keep_global_transform' is true, the node's global transform will be preserved if supported. Node2D, Node3D and Control support this argument (but Control keeps only position).
func (MoreArgs) ReplaceBy ¶
Replaces this node by the given 'node'. All children of this node are moved to 'node'.
If 'keep_groups' is true, the 'node' is added to the same groups that the replaced node is in (see AddToGroup).
Warning: The replaced node is removed from the tree, but it is not deleted. To prevent memory leaks, store a reference to the node in a variable, or use Object.Free.
func (MoreArgs) SetMultiplayerAuthority ¶
Sets the node's multiplayer authority to the peer with the given peer 'id'. The multiplayer authority is the peer that has authority over the node on the network. Defaults to peer ID 1 (the server). Useful in conjunction with RpcConfig and the MultiplayerAPI.
If 'recursive' is true, the given peer is recursively set as the authority for all children of this node.
Warning: This does not automatically replicate the new authority to other peers. It is the developer's responsibility to do so. You may replicate the new authority's information using MultiplayerSpawner.SpawnFunction, an RPC, or a MultiplayerSynchronizer. Furthermore, the parent's authority does not propagate to newly added children.
type PhysicsInterpolationMode ¶
type PhysicsInterpolationMode int //gd:Node.PhysicsInterpolationMode
const ( // Inherits [PhysicsInterpolationMode] from the node's parent. This is the default for any newly created node. // // [PhysicsInterpolationMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.PhysicsInterpolationMode PhysicsInterpolationModeInherit PhysicsInterpolationMode = 0 // Enables physics interpolation for this node and for children set to [PhysicsInterpolationModeInherit]. This is the default for the root node. PhysicsInterpolationModeOn PhysicsInterpolationMode = 1 // Disables physics interpolation for this node and for children set to [PhysicsInterpolationModeInherit]. PhysicsInterpolationModeOff PhysicsInterpolationMode = 2 )
type ProcessMode ¶
type ProcessMode int //gd:Node.ProcessMode
const ( // Inherits [ProcessMode] from the node's parent. This is the default for any newly created node. // // [ProcessMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ProcessMode ProcessModeInherit ProcessMode = 0 // Stops processing when [SceneTree.Paused] is true. This is the inverse of [ProcessModeWhenPaused], and the default for the root node. // // [SceneTree.Paused]: https://pkg.go.dev/graphics.gd/classdb/SceneTree#Instance.Paused ProcessModePausable ProcessMode = 1 // Process only when [SceneTree.Paused] is true. This is the inverse of [ProcessModePausable]. // // [SceneTree.Paused]: https://pkg.go.dev/graphics.gd/classdb/SceneTree#Instance.Paused ProcessModeWhenPaused ProcessMode = 2 // Always process. Keeps processing, ignoring [SceneTree.Paused]. This is the inverse of [ProcessModeDisabled]. // // [SceneTree.Paused]: https://pkg.go.dev/graphics.gd/classdb/SceneTree#Instance.Paused ProcessModeAlways ProcessMode = 3 // Never process. Completely disables processing, ignoring [SceneTree.Paused]. This is the inverse of [ProcessModeAlways]. // // [SceneTree.Paused]: https://pkg.go.dev/graphics.gd/classdb/SceneTree#Instance.Paused ProcessModeDisabled ProcessMode = 4 )
type ProcessThreadGroup ¶
type ProcessThreadGroup int //gd:Node.ProcessThreadGroup
const ( // Process this node based on the thread group mode of the first parent (or grandparent) node that has a thread group mode that is not inherit. See [ProcessThreadGroup] for more information. // // [ProcessThreadGroup]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ProcessThreadGroup ProcessThreadGroupInherit ProcessThreadGroup = 0 // Process this node (and child nodes set to inherit) on the main thread. See [ProcessThreadGroup] for more information. // // [ProcessThreadGroup]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ProcessThreadGroup ProcessThreadGroupMainThread ProcessThreadGroup = 1 // Process this node (and child nodes set to inherit) on a sub-thread. See [ProcessThreadGroup] for more information. // // [ProcessThreadGroup]: https://pkg.go.dev/graphics.gd/classdb/#Instance.ProcessThreadGroup ProcessThreadGroupSubThread ProcessThreadGroup = 2 )
type ProcessThreadMessages ¶
type ProcessThreadMessages int //gd:Node.ProcessThreadMessages
const ( // Allows this node to process threaded messages created with [CallDeferredThreadGroup] right before [Process] is called. // // [CallDeferredThreadGroup]: https://pkg.go.dev/graphics.gd/classdb/#Instance.CallDeferredThreadGroup // [Process]: https://pkg.go.dev/graphics.gd/classdb/#Instance.Process FlagProcessThreadMessages ProcessThreadMessages = 1 // Allows this node to process threaded messages created with [CallDeferredThreadGroup] right before [PhysicsProcess] is called. // // [CallDeferredThreadGroup]: https://pkg.go.dev/graphics.gd/classdb/#Instance.CallDeferredThreadGroup // [PhysicsProcess]: https://pkg.go.dev/graphics.gd/classdb/#Instance.PhysicsProcess FlagProcessThreadMessagesPhysics ProcessThreadMessages = 2 // Allows this node to process threaded messages created with [CallDeferredThreadGroup] right before either [Process] or [PhysicsProcess] are called. // // [CallDeferredThreadGroup]: https://pkg.go.dev/graphics.gd/classdb/#Instance.CallDeferredThreadGroup // [PhysicsProcess]: https://pkg.go.dev/graphics.gd/classdb/#Instance.PhysicsProcess // [Process]: https://pkg.go.dev/graphics.gd/classdb/#Instance.Process FlagProcessThreadMessagesAll ProcessThreadMessages = 3 )