N
N
Nolrox2021-12-31 15:44:01
Game development
Nolrox, 2021-12-31 15:44:01

How to make an invisible object visible and vice versa?

It is necessary for me that at pushing of the button, there was an object on a scene. So that when he clicks the button in the "Visibility" tab, the "Visible" option is turned off. Is it possible to do so? If so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DUbuntuGN3, 2022-01-24
@DUbuntuGN3

Get a reference to an object and pass a parameter to it.

var has_button_been_pressed = false
func _pressed():
    var button = get_tree().get_root().get_node("Node/Button")
    var panel = button.get_node("Panel")
    if (panel.visible == true and has_button_been_pressed == true):
        button.visible = false
    else:
        panel.visible = true
        has_button_been_pressed = true

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question