Advertisement
PlanetKiller

Godot Get Children Recursive

Mar 7th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # replaces the old get_children_recursive() function
  2. func get_recursive_children(node):
  3.     var childList = []
  4.     childList += [node]
  5.     var index = 0
  6.     while index < childList.size():
  7.         if(childList[index].get_child_count() > 0):
  8.             childList += childList[index].get_children()
  9.         index += 1
  10.     return childList
  11.    
  12.     pass
  13.    
  14. # list nodes in a given group, from a list of nodes
  15. func get_grouped_nodes(nodeList, group):
  16.     var nodes = []
  17.     for i in nodeList:
  18.         if i.is_in_group(group):
  19.             nodes += [i]
  20.     return nodes
  21.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement