0 votes

I am trying to make a button hide the wings when clicked. the button works when I don't add .hide() to the end but I want to hide the wings. I am getting this error:

Attempt to call function 'hide' in base 'null instance' on a null instance.

extends Panel

func _ready():
    set_fixed_process(true)

func _on_MenuButton_button_down():
    get_node("Player/Shane's-Wings").hide()
in Engine by (21 points)

Can you post a capture of the relevant part of your node tree, please?

1 Answer

0 votes

get_node("Player/Shane's-Wings") is the wrong path, as it's returning null. Use the correct path to the node there and it should work

by (313 points)

Still won't work I copied the path straight from the node by ctrl + c and pasted it in.

The path you're giving in your get_node() call is currently looking for a child of the button (this script's node) named "Player". My guess is this is probably not the case.

http://docs.godotengine.org/en/stable/classes/class_node.html?highlight=get_node#class-node-get-node

The get_node() documentation covers how these paths work pretty well. From that, you should be able to figure out the correct path according to your own game's scenetreee.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.