summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-09-01 12:35:55 +0200
committerGitHub <noreply@github.com>2020-09-01 12:35:55 +0200
commit877246a78e4316d8458456c1c34e1afa8619659b (patch)
treeae69d70593eec478a5e67f529b90ba598f02c1a4 /scene
parent0afabf6cb754da5ad95ccaf3ae1576f4d00a7b14 (diff)
parentbdf614d3d75551164fdd1eed7fb5539cafa30330 (diff)
Merge pull request #41505 from SekoiaTree/neg-get-child
Made get_child support negative indexes
Diffstat (limited to 'scene')
-rw-r--r--scene/main/node.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 653eb698d4..6b304c03d2 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1327,6 +1327,9 @@ int Node::get_child_count() const {
}
Node *Node::get_child(int p_index) const {
+ if (p_index < 0) {
+ p_index += data.children.size();
+ }
ERR_FAIL_INDEX_V(p_index, data.children.size(), nullptr);
return data.children[p_index];