Invalid call. Nonexistent function 'get_player' in base 'Viewport'

192 views Asked by At

I run the script

func search():
    var pl = get_parent().get_parent().get_player()

and I get the error Non-existent function 'get_player' in the base 'Viewport'.

what to do?

I have to get from the parent node

func get_player():
return $Player

but an error comes out Invalid call. Nonexistent function 'get_player' in base 'Viewport'.

1

There are 1 answers

0
Asavel On

If you don't know what your parent nodes are,do a print(get_parent().name) that way you will get to the node you suppose.

If your parent node has a child node "player" do: get_parent().get_parent().get_node("player")

Would be helpful if you would post a picture of your scene,if you want an accurate answer