How do i access a scene, that is added by multiple layers of instancing.

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

In my 2D main-scene i instanced the 3d game-scene.
than i instanced the level-scene in the game-scene through script-code and the player-scene in the level-scene the same way.

I need this setup to display two cameras at once, which use sprites as screens.
than the levels are instances to switch easily from one to another and the player is an instance to need only one player-scene for the whole game.

i tried


the first three names in this line are the variables, in which each instance is stored in the script of their parent-scenes.



Everything, that uses grid calculations, is child of the GridMap-node “Walls” in the level-scene, that provides all grid-calculations in it´s script.

First variant gives an invalid_get_index - error.
Second variant gives a call_function_get_viewport_at_null_index - error.

how can i now access the player scene in the main scene?

It´s because i want to play the view of the player-cam on a sprite in the 2D-main-scene.

Now i think, maybe the call for finding the camera runs faster, than the nested instance-steps are done.

So i thaught, maybe i can let the player emmit a custom signal at the end of it´s ready-function.

But how do i now connect the signal to the 2D-main-scene?

:bust_in_silhouette: Reply From: Drachenbauer

never mind

i now found a way my self:

I took the first person camera and viewport out of the player and into the game-scene, where the topdown-stuff already is Than i made the player call a function for the camere in process, that sets position and rotation of the camera to the values of the player.

so i could connect both cameras exact the same way to their matching sprite-screens.

now everything is correct placed: fitted gamescreen