Instanced scene not visible when deployed into CanvasLayer

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

this code spawns the dialogue scene into the canvaslayer

func _start_chat():
print("starting")
var dialoguebar = dialogue.instance()
#does spawn, but not visible
get_node(canvasLayer).add_child(dialoguebar)
dialoguebar.position = position

replacing the textbox with another scene to instance still instances a non-visible scene

making it instance as a child of the scene that runs the code instead of a child of CanvasLayer also makes the textbox not visible, but a different object spawned that way is visible
Objects already in the canvaslayer, like a health UI, or the scene i am trying to spawn, when the game starts are visible, but when they are instanced at runtime, they are not visible

the function does get called, the right scene is attached and does get deployed into the world. I’m not sure what else to share that would be relevant to this issue.

:bust_in_silhouette: Reply From: deaton64

Hello,
Is the object being instanced off screen somehow?
What is it’s global position when spawned?
I had an issue with with instances spawning and I couldn’t see them, they were just on the screen. I added a camera, made it active and zoomed out. There they were…

Thankyou! Turns out I was setting the position of the new scene to the position of the scene that instances it, had to use a magic vector to position it properly though, would be good to know how to fix that.
Currently works with dialoguebar.global_position = Vector2(160,152)

Aravash | 2020-07-01 22:28