Why is hotbar.hide() not hiding the hotbar.tscn?

Godot Version

v4.4.1.stable.official [49a5bc7b6]

Question

Hi,

I have a hotbar.tscn scene displayed in a player.tscn and I am trying to hide/show it by pressing the TAB key:

@onready var hotbar: Node3D = $Hotbar

func _unhandled_key_input(event: InputEvent) -> void:
	if event.is_action_pressed("ui_focus_next"):
		print("ui_focus_next hotbar.visible: ", hotbar.visible)
		if hotbar.visible:
			hotbar.hide()
		else:
			hotbar.show()

For some reason the hotbar never disappears from the screen eventhough I see the messages

ui_focus_next hotbar.visible: true
ui_focus_next hotbar.visible: false
ui_focus_next hotbar.visible: true
ui_focus_next hotbar.visible: false
ui_focus_next hotbar.visible: true
ui_focus_next hotbar.visible: false

What could be the reason here, does it matter that I use a 2nd camera (orthogonal, layers=2) to display the line of cubes in my “3D hotbar”?

Thank you!

I think the “visible” property might not be inherited between Node3D and control nodes

2 Likes

Thank you, I have not thought about that possibility! Fixed now by:

@onready var hotbar: Node3D = $Hotbar

func _unhandled_key_input(event: InputEvent) -> void:
	if event.is_action_pressed("ui_focus_next"):
		print("ui_focus_next hotbar.visible: ", hotbar.visible)
		if hotbar.visible:
			hotbar.hide()
			for c in hotbar.get_children():
				c.hide()
		else:
			hotbar.show()
			for c in hotbar.get_children():
				c.show()
1 Like