Creating hud in scene, loading scene as overlay

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

Hey there,

I am wondering if it is possible to create a scene (which includes for example a skill tree with functional scripting already included) which gets loaded as a overlay (which works) to the current scene/game.

I do not know if background loading is the correct thing for this.

Underneath I structured my idea:

-Main Game
–Kinematic Body (Player)
—Skilltree scene/hud
—Backpack scene/hud
----Currency window, crafting reagents window
—Character attribute scene/hud
----Main attributes
----Secondary attributes

Have you looked into putting the overlay scene together with Control nodes, and then adding that scene as an instance to the character’s scene? All of this can be done in the Godot editor, BTW. Once those have been designed and added, the overlay can be used with directly accessing the attached scripts from the root node, or using signals.

Ertain | 2022-01-08 21:34

Have not looked inside of this yet as I do not have an idea which function/scene methods could be valueable for it.

I used by main game scene and try to add the scene with character’s attribute to it with a keyboard input and it is currently not working with that method. The general scene instancing (loading scene in _ready function) is working.

The debugger shows, that the child process itself get’s connected. Any suggestions? I found a similiar problem: Reddit - Dive into anything

Maingame.gd

extends Node2D
var Charakterwerte = load("res://Scenes/Interface/Charakterwerte.tscn")
var Charakterwerte_Instance = Charakterwerte.instance()

func Tastatur(event):
	if event is InputEventKey:
		if event.pressed and event.scancode == KEY_SPACE:
			Charakterwerte_Instance.set_name("Charakterwerte")
			add_child(Charakterwerte_Instance)

I tried to move the variables into the function without success.

func Tastatur(event):
    		if event is InputEventKey:
	if event.pressed and event.scancode == KEY_SPACE:
		var Charakterwerte = load("res://Scenes/Interface/Charakterwerte.tscn")
		var Charakterwerte_Instance = Charakterwerte.instance()
		Charakterwerte_Instance.set_name("Charakterwerte")
		add_child(Charakterwerte_Instance)

Fyrion | 2022-01-09 12:15

If you didn’t know, some Control nodes are set to consume input by default (e.g. some don’t allow mouse clicks to propagate). For mouse clicks, look for mouse filtering in the Inspector for each Control node.

Have you looked into using the _gui_input() function to handle Control related code? That function handles GUI stuff before any player inputs (more information on that input can be found here).

Ertain | 2022-01-09 19:01