Skip to content

Search

Documentation

node

What every node has: name, path, transform, children, components and script. Each function takes the node first; scripts call it as a method…

On this page

What every node has: name, path, transform, children, components and script. Each function takes the node first; scripts call it as a method, self.node.get_node("Arm").

60 functions, 0 constants. Scripts reach it as node::.

Acts on states, transform: those functions are also methods on the component's handle, without the node argument.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
add_child(Node, string) -> Node — Create a named child node under this one and return it.
add_tag(Node, string) — File the node under a name; scene.tagged finds it from then on.
attach_script(Node, string, any) — Attach the script at a path, with an optional table overriding what the script exports.
authored(Node, string) -> any — The component as a save writes it: every property it holds, an inline asset as its definition, a colour as #rrggbb where it is one, and no read-only property. Nil when the node does not carry it.
call(Node, string, any, any, any, any) -> any — Call a method on the node's script and return what it gives back; nil when there is no such script or method.
call_async(Node, string, any, any, any, any) -> int — Call a method that may suspend, and get a token task.wait resumes with its result once it returns: task::wait(door.call_async("open")).await, a GDScript await door.open().
children(Node) -> [Node] — The node's direct children, an empty list when it has none.
component_names(Node) -> [str] — The names of every component on the node.
component_property(Node, string, string) -> any — One property of the named component, nil when the node does not carry it: what a caller reading a single value should ask for.
descendants(Node) -> [Node] — Every node under this one, in tree order, the node itself excluded.
detach_script(Node) — Drop the script instance on this node, so no further lifecycle call reaches it; the node and its components stay.
effective_material(Node) -> string — The material the node draws with: its own, or the nearest ancestor's. Empty is the built-in one.
effective_tint(Node) -> Color — What the renderer multiplies by: this node's tint with every ancestor's folded in.
effective_z_index(Node) -> int — The layer the node actually draws on, with every ancestor's added in.
emit(Node, string, any) — Emit an event from this node, delivered at the top of the next frame to whoever subscribed to name on this node, and to whoever subscribed to name from anyone. call is the twin that reaches one known script, now.
free(Node) — Destroy the node and its subtree now, scripts detached first: what a tool editing a scene does, where no script of the subtree is running. A game frees with queue_free.
get_component(Node, string) -> any — The named component's properties as a table, nil when the node does not carry it.
get_node(Node, string) -> Node — The node at an A/B/C path relative to this one, .. climbing to the parent and a leading / starting from the root; nil when nothing matches.
global_position(Node) -> Vec3 transform The node's position in world space, as of the last transform sync.
global_rotation_euler(Node) -> Vec3 transform The node's world rotation as euler angles in radians, as of the last transform sync.
global_scale(Node) -> Vec3 transform The node's scale in world space, as of the last transform sync.
has_component(Node, string) -> bool — Whether the node carries the named component.
has_method(Node, string) -> bool — Whether the node's script declares this method, so a caller can tell "no handler" from "a handler that answered nothing".
has_tag(Node, string) -> bool — Whether the node is filed under a name.
instance(Node) -> str? — The prefab file the node instances, nil when it instances none.
is_valid(Node) -> bool — Whether the node is still in the world; false rather than an error when the value is not a node.
material(Node) -> string — The material asset the node names itself, empty when it takes its parent's.
name(Node) -> string — The node's own name, empty when it carries none.
overrides(Node) -> any — What the node changes of what the prefab that built it asks: a table by component of the properties it sets differently, and its script's under script. Empty for a node no prefab built.
parent(Node) -> Node — The node's parent, nil at the root.
patch_component(Node, string, any) -> bool — Change the properties the table names and leave the rest of the component where they were. On a node without the component this adds it, the schema defaults being what it currently holds. Answers whether the component took the values: one it refuses goes to the log with its reason, and the script goes on. A component or property nothing has, or a node that is gone, is an error.
path(Node) -> string — The node's slash-separated path, built by climbing parents from the node up to the root.
process(Node) -> string — When this node ticks: "inherit", "pausable", "always" or "disabled". "inherit" is the default and takes the nearest ancestor's answer.
queue_free(Node) — Destroy the node and its subtree at the end of the frame.
remove_component(Node, string) — Take the named component off the node.
remove_tag(Node, string) — Take a name off the node; a name it never had is left alone.
reset_interpolation(Node) — Throw away the poses the node was blending and start again from where it is, so a teleport does not streak across the level. physics3d.teleport and physics2d.teleport call it for you.
script_field(Node, string) -> any — A member the node's script instance holds, read by another script: GDScript's node.speed. Nil for no script or no such member.
script_path(Node) -> string — The path of the script the node names, nil when it names none; named whether or not it runs.
script_props(Node) -> any — What the node sets over its script's exported defaults, as a table; empty when it sets nothing.
set_component(Node, string, any) — Give the node the named component, built from the given table over the component's schema defaults. Every property the table leaves out goes back to its default; patch_component is the one that changes a property and leaves the rest. A script hears every write to the scene, this one and a node added, freed, renamed or moved, with events::listen(this.node, "changed"), as on_changed(entries) at the top of the next frame.
set_name(Node, string) — Rename the node, doing nothing when it carries no name.
set_parent(Node, Node) — Move the node under another, keeping where it is in the world; an error for a cycle or a dead parent.
set_process(Node, string) — Set when the node and its subtree tick. "always" runs through a pause, which is what a pause menu is; "disabled" never runs; "inherit" goes back to the parent's. Physics is one world and is held whole by a pause whatever this says.
set_property(Node, string, string, any) -> bool — Write one property, by its place in the component: what node.component.property writes, for a name known only at run time. Answers whether the component took the value, as patch_component does.
set_script(Node, str?, any) — Name the node's script and what it sets, without running it: what a scene's script key says and attach_script also starts. Nil takes the script off.
set_sibling_index(Node, int) — Move the node to that place among its siblings, clamped to the end. Order is draw order in a row or a column, and tree order in the digest.
set_state(Node, string) states Put the node in one of its states: the state's table is patched over the components it names, and on_state_changed(from, to) follows. A node already in that state is left alone.
set_tint(Node, float, float, float, float) — Multiply a colour into everything the node and its subtree draw, alpha included, one meaning untinted. A renderable's own color is the node's alone; this is the one that inherits.
set_visible(Node, bool) — Show or hide the node and everything under it, emitting visibility_changed with the new value when the flag moves. Physics is untouched: a hidden collider still collides.
set_z_index(Node, int, bool?) — Put the node and its subtree on a draw layer: higher draws later. It adds to the parent's layer unless relative is false, which makes it absolute.
sibling_index(Node) -> int — Where the node sits among its parent's children, counting from zero; 0 at the root.
stable_id(Node) -> string — The node's stable id: what a scene file declared, or what it was given when it was spawned. Survives rename and reparent, which a path does not.
state(Node) -> string states The state the node is in, or "" for the pose the scene gave it.
tags(Node) -> [str] — The names the node is filed under, sorted.
ticking(Node) -> bool — Whether the node ticks this frame, its process mode and the game's pause together.
tint(Node) -> Color — The node's own tint as r, g, b, a channel floats; an ancestor's multiplies into it on the way to the screen.
visible(Node) -> bool — Whether the node itself is set to draw; an ancestor may still hide it.
visible_in_tree(Node) -> bool — What the renderer sees: false when the node or any ancestor is hidden.
z_index(Node) -> int — The node's own draw layer, added to its parent's unless set absolute.

Are you sure?