1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 23:54:23 +00:00
hella-farm/traversal.gd

12 lines
326 B
GDScript3
Raw Normal View History

2024-04-19 02:30:35 +00:00
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