mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-25 09:34:24 +00:00
12 lines
326 B
GDScript3
12 lines
326 B
GDScript3
|
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
|