Is my understanding of visible node property in Godot right?

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

So visible property is a for godot to know what node will be calculated in screen. It can change through toggle visibility button in scene menu or by .visible property.

Everything that visible will be calculated. (All script and all of it childern nodes)
And if the visiblitity is false then, the script stop working and all of it childerns.

Not like .free() and .queuefree(), where free still in memory but can’t accsess anymore and queuefree release from memory. Visible only tell the godot game loop to not calculate and show it to the screen.

Is my understanding is right?

:bust_in_silhouette: Reply From: Starfighter

Hi,
Visibility only allows to a node to display or not his content on screen.
But the code of a node with “visibility == false” will still be executed.

eg.

Add a 2d child node to your scene and set his visibility to false.

In this child node add this code:

func _process(delta):
     print ("running....")

Then run the scene, you will see that the hidden node will run the code.

Edit:
If you want the code to be executed only when the node is visible you can use this:


func _process(delta):
    if self.visible:
	    print ("running....")

cheers

Ah yes… I forget. And yes the _ready and _process function still being called.

But I think, I am confusing my case with general nodes. TouchScreenButton node if visible = false doesn’t detect if the screen being touched.

Sorry for late reply. Thank you verry much btw.

molesallegiance | 2022-10-11 12:47