Phazorknight / Cogito

Immersive Sim Template Project for GODOT 4
MIT License
652 stars 71 forks source link

SubViewport as Root causes errors #219

Open skrunkleVEVO opened 1 week ago

skrunkleVEVO commented 1 week ago

Cogito and Godot Engine Version: Cogito Master (June 18th) / Godot 4.2.2 stable

Description: Making a new scene, and making a subviewport container and a subviewport parents of the node3D containing the environment/level, gives me this error. image

Reproduction steps:

Make any 3D scene/3D root node a child of a SubViewportContainer with a SubViewport, and simply start the scene. Making a new scene from scratch, with the ViewPort as a root, and the 3D node containing the level does not fix the issue either.

Expected behavior: No issues? Doing this never caused an issue during older versions with the legacy demo.

By the way, I am very new to Godot, so forgive me if this is just a simple fix that I am not aware of.

Phazorknight commented 1 week ago

Hey, sorry I won't be able to look into this more until next week as I'll be out of town.

I think this bug didn't occur in the older versions as the display options from the options menu weren't all added yet.

You could try to comment out the content of the function that sets the GUI scale and see if that helps (though I suspect you might run into a different error further down: image

This of course would stop the GUI scaler from working but that might not be a big deal for you.

Seems to be the main issue would be getting the right properties of a subviewport or the camera that's within it.

Phazorknight commented 2 days ago

Hey, so I've spent a little bit of time playing around with this.

I've managed to get a subviewport going and excluded the HUD (cause I assume any viewport shaders shouldn't affect the UI)

This is node my setup: image

Please note that I've removed the PlayerHUD and PauseMenu from the Player.tscn and instead added them here manually and then assigned them in the inspector of the Player.tscn.

This seems to get at least the expected results visually, but I mouse input stops working when doing it this way (gamepad input still works).

Also as soon as any script calls get_camera_3d() it errors out. I assume this shouldn't be too hard to fix by updating the few occasions to something else.

skrunkleVEVO commented 7 hours ago

Sorry for my delayed response. I tried doing something similar, but I get the error "Invalid get index 'player_interaction_component'" I assume the node "Level" in the screenshot is a node 3D which contains all the 3D nodes and prefab scenes? I instead just put the contents of "Cogito05DemoLaboratory" into a subviewport, along with the player, but I can't seem to get the project to work. I also tried this on today's commit version, but no luck. Sorry I can't help you troubleshoot the mouse input, but I can't seem to get to the point you are at. image image

Phazorknight commented 7 hours ago

Oh, if you move the PlayerHUD and the Pause Menu outside of the Player.tscn, you need to manually set the references.

In this case, I assume that error is cause by the PlayerHUD node not having a reference set to the Player node. Doing that should fix this.

skrunkleVEVO commented 7 hours ago

Got it, it was just the playerhud that didn't have a reference set, thanks for the fix!

skrunkleVEVO commented 7 hours ago

Now I see what you mean, my mouse movements don't affect the player, and I can't click or hover over anything either. I'll try and look into this later.