Skip to content

Invert Camera2D zoom values to make it intuitive #3888

Description

@madmiraal

Describe the project you are working on

Allowing the user to use the scroll wheel to zoom in and out of the map.

Describe the problem or limitation you are having in your project

When adjusting a Camera2D's zoom property, the values are inverted:

The camera's zoom relative to the viewport. Values larger than Vector2(1, 1) zoom out and smaller values zoom in. For an example, use Vector2(0.5, 0.5) for a 2× zoom-in, and Vector2(4, 4) for a 4× zoom-out.

Currrently a zoom of Vector(2, 2) halves the size of objects in the viewport. Similarly, a zoom of Vector(0.5, 0.5) doubles the size of objects in the viewport:

No Zoom Zoom: (2, 2) Zoom: (0.5, 0.5)
Zoom x1 - Current Zoom x2 - Current Zoom x0 5 - Current

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

I would expect values greater than 1 to increase the zoom and values less than 1 to decrease the zoom. A zoom of Vector(2, 2) should double the size seen in the viewport. Similarly, a zoom of Vector(0.5, 0.5) should halve the size seen in the viewport:

No Zoom Zoom: (2, 2) Zoom: (0.5, 0.5)
Zoom x1 - Current Zoom x0 5 - Current Zoom x2 - Current

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

This would be a case of simply inverting the values inside the engine.
See godotengine/godot#57392

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

Yes, but this is what I want to avoid.

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

It's how the engine treats Camera2D's zoom property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions