godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 93 forks source link

Add ViewPort Camera3D when running a 3D scene without Camera #5801

Open golddotasksquestions opened 1 year ago

golddotasksquestions commented 1 year ago

Describe the project you are working on

This applies to any Godot 3D project.

Describe the problem or limitation you are having in your project

Unlike 2D scenes, 3D scenes in Godot require to user to add a Camera. If the user does not add a Camera and tries to run a 3D scene with a 3D root node, all they see is grey.

This is because Godot will then by default render the 2D portion of the scene. When the scene does not have any 2D nodes however, Godot will just render the default 2D background, which by default is grey:

If I try to run this scene

(Godot3.X): image

(Godot4 Beta5): image

All I see is the grey default 2D CanvasItem environment background: image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

If the root node inherits in from Node3D and there is no Camera3D in the scene, add one with the same transforms as the Editor Viewport Camera whenever the user plays the scene or hits F6.

This is the same as adding a Camera3D node and pressing Ctrl+Alt+M while the Camera3D node is selected before running the game.

Having this feature would provide the same usability and convenience Godot has when working with 2D scenes.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

See above

If this enhancement will not be used often, can it be worked around with a few lines of script?

Workarounds and custom utility are the opposite of helping with convenience and usability for commonly used features such as this.

Is there a reason why this should be core and not an add-on in the asset library?

It would make the workflow experience, convenience and therefore usability of 2D and 3D much more similar if this would work out of the box.

Calinou commented 1 year ago

Related to https://github.com/godotengine/godot-proposals/issues/5800. I share the same concern as in that other proposal with regards to behavior suddenly changing when you export the project.

golddotasksquestions commented 1 year ago

I share the same concern as in that other proposal with regards to behavior suddenly changing when you export the project.

I don't share this concern at all because this action takes place only when running the editor. So when you press this button or F6 while the Editor is running image

So the way I see it it has nothing to do with an exported project.

QbieShay commented 1 year ago

We should probably have a warning in the console when running a 3D project with no camera. I don't think adding an automagic camera is a good idea, i believe it will cause more confusion later on.

YuriSizov commented 1 year ago

We should probably have a warning in the console when running a 3D project with no camera.

This is more about running individual scenes for testing purposes and having to define a camera for them to be usable, which is also an issue in 2D (in 3.x as well). Though I guess in 2D we can at least see something. Wonder if we could have a clever viewport trick when running scenes so that it has an internal camera which focuses on the object in the tested scene.

QbieShay commented 1 year ago

This is more about running individual scenes for testing purposes

Could apply to any scenetree with 3D nodes and no camera

ptlthg commented 1 year ago

I think this would be a nice QOL improvement for testing individual 3D scenes.

To address the concerns of beginners not realizing that they're missing a camera for exports, a couple of things can be done:

  1. Send a console warning when running the main scene when it's missing a camera.
  2. Add an "Are you sure you want to continue?" popup explaining that the main scene is missing a camera and won't display anything when exporting (With a "Don't show again" option).

The way I see it, this makes testing individual scenes way easier with no downsides. It even helpfully warns beginners that they need a camera in their scene.

timothyqiu commented 1 year ago

Maybe we can reuse the "Project Camera Override" feature.

For example, when running individual 3D scenes and there's no camera defined, auto check the "Project Camera Override" button.

GalanCM commented 1 year ago

For anyone that's interested, I've made a plugin that does this: https://github.com/GalanCM/godot-test-camera-3d. It's still early, but depending on interest I could look into porting it to the engine proper.