1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 15:44:23 +00:00
hella-farm/traversal.gd
2024-04-19 04:30:35 +02:00

11 lines
326 B
GDScript

class_name Traversal
## Get the first possible [MainGame] instance by climbing the scene tree one ancestor at a time.
static func get_ancestors(start: Node) -> Array[Node]:
var result: Array[Node] = []
var current = start
while current is Node:
result.push_back(current)
current = current.get_parent()
return result