I don't want use: node.GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetChild(0).Name
This form of code is not professional.
Thanks.
Radiobiology some kind of queuing or recursion, perhaps? Seems like you're after a specific node rather than all children so perhaps less than optimal to descend through the tree, although the found node is going to be the terminating condition (or when you run out of nodes). If you know the node you want, why not use FindChild
instead (which is recursive) or perhaps GetNodesInGroup
(and assign it to a group)?
Perhaps also consider having an NodePath
export and dragging the node you seek into the Inspector.
The recursive/queue solution would involved checking GetChildren
(with a non-empty result) and then essentially calling the same function (or adding to queue) with the current node as the start point. But I'd avoid and leverage godot's other functions instead.
Radiobiology I don't use C# but GDScript has find_children. Does that not exist in C#?
Radiobiology some kind of queuing or recursion, perhaps? Seems like you're after a specific node rather than all children so perhaps less than optimal to descend through the tree, although the found node is going to be the terminating condition (or when you run out of nodes). If you know the node you want, why not use FindChild
instead (which is recursive) or perhaps GetNodesInGroup
(and assign it to a group)?
Perhaps also consider having an NodePath
export and dragging the node you seek into the Inspector.
The recursive/queue solution would involved checking GetChildren
(with a non-empty result) and then essentially calling the same function (or adding to queue) with the current node as the start point. But I'd avoid and leverage godot's other functions instead.
Radiobiology What's your actual goal here?
Sitzmark Finally fixed with FindChild()
Function. Thanks!
© 2022 - 2024 — McMap. All rights reserved.