• 3D
  • Creating multiple scene instances from same scene

Hey guys,

I'm somehow strugeling to get something work in gdscript and have encountered an issue that I don't know how to fix, or if it's even a bug. I'll be glad if you could help me out.

So here is my problem: I'm having a scene that looks like this in the scene graph and like this while running.

Now I want to instance two of this scenes in another scene. So far its working just fine. And it looks as followed:

My issue starts as soon as i want to roatate one of the objects within the viewport. Here is the script that I'm using. and the result looks kinda odd. It looks like every object in the viewport is doubled when instancing the scene twice.

If you can help me out or have an idea why it works like this I'd be appreciated.

BaseCrusher

Is own world checked on the Viewport nodes? Checking own world should make it where the child nodes of the Viewport are all that the Viewport can render. It could be that both of the instanced Viewport nodes are using the same world, so they both see and render all of the nodes in the scene.

Other than that, I'm not sure. If that does not work, I'll see if I can replicate the issue in a test project. Hopefully this helps!

Yes, that did the it. Thank you so much. I was kinda struggeling wiht this issue. Though I do not know why this is even a thing. I mean I have no idea when you want to use the same world. Or what's the reason this option exists? Just wondering.

Great! I'm glad that fixed it :smile:

Though I do not know why this is even a thing. I mean I have no idea when you want to use the same world. Or what's the reason this option exists?

You might want to use the same world if you want to use the Viewport to get a different view. For things like mirrors, mini-maps, and local-multiplayer games, using the same world makes sense as you primarily just want a different camera view, not necessarily a completely different world. It primarily depends on how the scene is setup, what needs to be seen in the Viewport node, and how the Viewport texture is going to be used.

@TwistedTwigleg said: Great! I'm glad that fixed it :smile:

Though I do not know why this is even a thing. I mean I have no idea when you want to use the same world. Or what's the reason this option exists?

You might want to use the same world if you want to use the Viewport to get a different view. For things like mirrors, mini-maps, and local-multiplayer games, using the same world makes sense as you primarily just want a different camera view, not necessarily a completely different world. It primarily depends on how the scene is setup, what needs to be seen in the Viewport node, and how the Viewport texture is going to be used.

Putting it like this seams to make sense. Thank you very much for the explanation.

One last question. I do not know if I'm doing something wrong, but when checking the own world in the viewport, all the 3D objects within the preview window of godot are invisible, like they are there, you can move and roatate them but they are jsut invisible. But when the scene is running, they are shown. Any idea what I've done wrong?

@BaseCrusher said: One last question. I do not know if I'm doing something wrong, but when checking the own world in the viewport, all the 3D objects within the preview window of godot are invisible, like they are there, you can move and roatate them but they are jsut invisible. But when the scene is running, they are shown. Any idea what I've done wrong?

I do not think you have done anything wrong, as far as I know this always happens. I have never found a way around it.

The way I get around it through one of two ways:


The first way is to create a new scene and position everything I want to be in the viewport normally. I then save this scene and make it an instanced child node of the Viewport. Then I can edit, attach scripts, and use the Godot editor like normal. So long as you do not need to position nodes relative to the main game scene/window, this method works pretty well.

The other way is to move all of the nodes to another node, make any edits you need, and then re-parent them to the Viewport node. When the nodes are not parented to the Viewport node they will be visible again and you can use them like every other node in the scene. Then before running/saving the scene, you'll need to remember to re-parent the nodes again so they are children of the Viewport node so the Viewport can see them. This method requires a bit more manual work, but it has the benefit if not needing an instanced scene and it is easier to position the nodes relative to nodes in the main game scene/window.


That is what I do at any rate. There might be a way to see the nodes within a Viewport set to use its own world, I just don't know what it is, though I would love to know if there is a way! Editing the nodes without being able to see them is a pain, so I use one of the two methods above (or both) to work around the issue.