How to get position/index of node within hierachy

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sombat92

I’m trying to make a Flappy Bird game, where a game manager attached to the scene node creates pipes every second. I also have a base which has a script. I’ve seen that using raise() noticeably affects performance, so I’m trying to check if the base isn’t at the front of the hierachy before using raise(). How would I do this? Is there a built-in function (like get_tree().get_index_in_hierachy(), or do I have to code it myself?

Any help would be greatly appreciated.

Could you add a few more details? What does the raise() function do? What is a “base” in this instance?

Just from a documentation point of view, you could probably do:

if(base.get_parent().get_child(0) != base)

Kanor | 2020-12-13 15:25

Your code worked, thanks!
raise()is a built-in function that raises a node to the top of hierachy (DOCS), but it is pretty intensive.

sombat92 | 2020-12-13 16:21

:bust_in_silhouette: Reply From: sombat92

Kanor’s comment.

if get_parent().get_child(0) != self:
    raise()