Click or drag to resize

NodeGetNode Method (NodePath)

Fetches a node. The NodePath can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a null instance is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error.

Note: Fetching absolute paths only works when the node is inside the scene tree (see IsInsideTree).

Example: Assume your current node is Character and the following tree:

/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin

Possible paths are:

get_node("Sword")
get_node("Backpack/Dagger")
get_node("../Swamp/Alligator")
get_node("/root/MyGame")

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public Node GetNode(
	NodePath path
)

Parameters

path
Type: GodotNodePath

[Missing <param name="path"/> documentation for "M:Godot.Node.GetNode(Godot.NodePath)"]

Return Value

Type: Node

[Missing <returns> documentation for "M:Godot.Node.GetNode(Godot.NodePath)"]

See Also