Skip to content

Commit 447cbde

Browse files
committed
Merge pull request godotengine#93890 from hakro/nodeprop-vs-nodepath
Add `:` to node properties, to differentiate them from node paths
2 parents 640d815 + 54d6c9e commit 447cbde

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

doc/classes/NodePath.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
[/codeblock]
2424
Despite their name, node paths may also point to a property:
2525
[codeblock]
26-
^"position" # Points to this object's position.
27-
^"position:x" # Points to this object's position in the x axis.
26+
^":position" # Points to this object's position.
27+
^":position:x" # Points to this object's position in the x axis.
2828
^"Camera3D:rotation:y" # Points to the child Camera3D and its y rotation.
2929
^"/root:size:x" # Points to the root Window and its width.
3030
[/codeblock]
31+
In some situations, it's possible to omit the leading [code]:[/code] when pointing to an object's property. As an example, this is the case with [method Object.set_indexed] and [method Tween.tween_property], as those methods call [method NodePath.get_as_property_path] under the hood. However, it's generally recommended to keep the [code]:[/code] prefix.
3132
Node paths cannot check whether they are valid and may point to nodes or properties that do not exist. Their meaning depends entirely on the context in which they're used.
3233
You usually do not have to worry about the [NodePath] type, as strings are automatically converted to the type when necessary. There are still times when defining node paths is useful. For example, exported [NodePath] properties allow you to easily select any node within the currently edited scene. They are also automatically updated when moving, renaming or deleting nodes in the scene tree editor. See also [annotation @GDScript.@export_node_path].
3334
See also [StringName], which is a similar type designed for optimized strings.

0 commit comments

Comments
 (0)