From bdf614d3d75551164fdd1eed7fb5539cafa30330 Mon Sep 17 00:00:00 2001 From: SekoiaTree Date: Tue, 25 Aug 2020 14:46:33 +0200 Subject: Made get_child support negative indexes, with documentation --- scene/main/node.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scene/main') 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]; -- cgit v1.2.3