Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make get_viewport().get_camera() able to return a Camera2D node instead of a Camera3D #2620

Open
tavurth opened this issue Apr 17, 2021 · 5 comments

Comments

@tavurth
Copy link

tavurth commented Apr 17, 2021

Describe the project you are working on

Any project which requires a 2D camera

Describe the problem or limitation you are having in your project

get_viewport().get_camera() returns null in 2D scene

The documentation specifically states that this function returns a Camera3D, however it is strange that in 2D scenes it does not return the Camera2D

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

Return Camera2D or Camera3D as a Variant

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

Please see above

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

Not so easily, I could add my cameras to groups and then search for them but it's not ideal.

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

This seems like a core feature

@Calinou
Copy link
Member

Calinou commented Apr 17, 2021

What if the scene has both a 2D and 3D camera active at the same time? While uncommon, this is technically possible.

@Calinou Calinou changed the title get_viewport().get_camera() returns null in 2D scene Make get_viewport().get_camera() able to return a Camera2D node instead of a Camera3D Apr 17, 2021
@tavurth
Copy link
Author

tavurth commented Apr 17, 2021

Questions to myself to answer your question @Calinou:

If I have two cameras set as active inside the current viewport what happens?
If I have two cameras set as active inside a 3D scene what happens?

I tested the 2D case and the last camera in the tree is used as the primary camera for the scene.
It seems like when you select one camera as current the other cameras become inactive.

In general in 2D I'd expect that last camera to be returned and in 3D the same.

It seems like get_viewport().get_cameras() or get_viewport().get_active_cameras() (i.e. observers) might be a better naming for those array use-cases where we have possibly multiple cameras.

In the case of mixed 2D and 3D cameras I guess the Node itself could determine which camera to pull? (I.e spatial pulls 3D cameras and Node2D pulls 2D cameras)

@Jummit
Copy link

Jummit commented Apr 17, 2021

See godotengine/godot#38317

@dalexeev
Copy link
Member

Maybe get_camera3d() and get_camera2d()?

@aaronfranke
Copy link
Member

I think get_camera_3d() and get_camera_2d() would be more in line with Godot's naming conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants