node module
What every node has: name, path, transform, children, components and script. Each function takes the node first; scripts call it as a method…
Sur cette page
What every node has: name, path, transform, children, components and script. Each function takes the node first; scripts call it as a method, this.node.get_node("Arm").
56 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(name: string) |
— | Create a named child node under this one and return it. |
add_tag(node, tag: string) |
— | File the node under a name; scene.tagged finds it from then on. |
attach_script(path: string, props: any?) |
— | Attach the script at a path, with an optional table overriding what the script exports. |
call(method: string, args: 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(method: string, args: any?) |
— | 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() |
— | The node's direct children, an empty list when it has none. |
component_names() |
— | The names of every component on the node. |
descendants() |
— | Every node under this one, in tree order, the node itself excluded. |
detach_script() |
— | Drop the script instance on this node, so no further lifecycle call reaches it; the node and its components stay. |
effective_material(node) |
— | The material the node draws with: its own, or the nearest ancestor's. Empty is the built-in one. |
effective_tint(node) |
— | What the renderer multiplies by: this node's tint with every ancestor's folded in. |
effective_z_index(node) |
— | The layer the node actually draws on, with every ancestor's added in. |
emit(name: string, payload: 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. |
get_component(component: string, key: string?) |
— | The named component's properties as a table, nil when the node does not carry it. With a key, that one property rather than the table, which is what a caller reading a single value should ask for. |
get_node(path: string) |
— | 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() |
transform |
The node's position in world space, as of the last transform sync. |
global_rotation_euler() |
transform |
The node's world rotation as euler angles in radians, as of the last transform sync. |
global_scale() |
transform |
The node's scale in world space, as of the last transform sync. |
has_component(component: string) |
— | Whether the node carries the named component. |
has_method(method: string) |
— | Whether the node's script declares this method, so a caller can tell "no handler" from "a handler that answered nothing". |
has_tag(node, tag: string) |
— | Whether the node is filed under a name. |
interpolate(node) |
— | Whether the node is drawn between fixed steps. |
is_valid() |
— | Whether the node is still in the world; false rather than an error when the value is not a node. |
material(node) |
— | The material asset the node names itself, empty when it takes its parent's. |
name() |
— | The node's own name, empty when it carries none. |
parent() |
— | The node's parent, nil at the root. |
patch_component(component: string, params: table) |
— | 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. |
path() |
— | The node's slash-separated path, built by climbing parents from the node up to the root. |
process(node) |
— | When this node ticks: "inherit", "pausable", "when_paused", "always" or "disabled". "inherit" is the default and takes the nearest ancestor's answer. |
queue_free() |
— | Destroy the node and its subtree at the end of the frame. |
remove_component(component: string) |
— | Take the named component off the node. |
remove_tag(node, tag: 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(name: string) |
— | 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() |
— | The path of the script attached to the node, nil when it has none. |
set_component(component: string, params: 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. |
set_interpolate(node, on: bool) |
— | Draw the node between fixed steps, or stop. Needs [time] interpolate on; a body and a script with fixed_update ask for it on their own. |
set_material(node, material: string) |
— | Draw the node and every descendant naming none with a material asset; empty goes back to the parent's. |
set_name(name: string) |
— | Rename the node, doing nothing when it carries no name. |
set_parent(parent: 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, mode: string) |
— | Set when the node and its subtree tick. "always" runs through a pause, which is what a pause menu is; "when_paused" runs only while paused; "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_sibling_index(index: 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(state: 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, r: float, g: float, b: float, a: 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, on: 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, z: int, options: map?) |
— | Put the node and its subtree on a draw layer: higher draws later. It adds to the parent's layer unless z_as_relative = false makes it absolute. |
sibling_index() |
— | Where the node sits among its parent's children, counting from zero; 0 at the root. |
stable_id() |
— | 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() |
states |
The state the node is in, or "" for the pose the scene gave it. |
tags(node) |
— | The names the node is filed under, sorted. |
ticking(node) |
— | Whether the node ticks this frame, its process mode and the game's pause together. |
tint(node) |
— | The node's own tint as r, g, b, a channel floats; an ancestor's multiplies into it on the way to the screen. |
translate(x: float, y: float, z: float) |
transform |
Move the node by an offset in its parent's space, given as three numbers or one vector. |
visible(node) |
— | Whether the node itself is set to draw; an ancestor may still hide it. |
visible_in_tree(node) |
— | What the renderer sees: false when the node or any ancestor is hidden. |
z_index(node) |
— | The node's own draw layer, added to its parent's unless set absolute. |