Godot Version
4.2.1
Question
Hi everyone,
In a game I’m making I have two scenes. One scene is an office with a computer showing a bodycam feed. I’m using a subviewport node to display the bodycam image onto the computer’s screen mesh. My second scene is the actual area where the bodycam video is being rendered.
My problem is that I want to add a feature where the character in the office can sit and the computer and the player’s camera/character will switch to the bodycam character.
Does anyone know how this would be possible? I tried to set the camera the subviewport is rendering to be the current camera but it didn’t display anything. The only thing I could think of is rendering the bodycam camera to both the main viewport and subviewport somehow, but I don’t think this is possible.
Thanks
Was able to find a way to do this, though it’s pretty hacky. But if it works, it works.
Here was my solution:
I restructured all my nodes to follow this format:
I have two SubViewportContainers under the root node. One for the bodycam/computer view, and another for the office worker view. Inside the containers I set the following parameters:
Setting this causes the container to fill the screen so it overrides the main viewport. Inside the containers I have a SubViewport node for rendering each camera. And inside each SubViewport I have a node for each player, with a camera to render to each individual viewport, as well as all relevant nodes for the different areas.
To switch viewports, just set the BodycamView visibility to false, so BodycamView.visible = false. This will hide it and instead render OfficeView.
From here, you can just write a simple script. Press a button and hide either OfficeView or BodycamView depending on the camera you want to view. You can also use the viewport’s to render the camera onto a texture (like how I am rendering the Bodycam viewport onto a camera in the office scene).
Like this:
“Office View”:
“BodyCam View”: