-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add examples for common coordinate conversions (a.k.a. Godot 2D coordinate system is incomprehensible) #11846
Description
Your Godot version: 4.6
Issue description:
I've been in games for 15 years and somewhat used to having different coordinate systems for viewports, UI, and world space. But when I have to do any conversions between coordinate systems in Godot, I land on this monstrosity of a chart and become completely paralyzed:
Right, so, it's complicated, and probably for good reasons! However, that is not generally the experience of the average game developer using Godot; they'll work in a 2D or a 3D scene or in a UI scene and generally don't have to deal with any of that complexity. But then there are moments, eg. when working with InputEvents, where users are forced into working with / understanding this complexity, and the documentation fails to bridge the gap between the 'simple' context of the scenes, and the extremely complicated context of the internal coordinate systems of the engine.
I found a few other pages (links at the bottom) that all fail to address some common coordinate system conversions. The documentation desperately needs to bridge this knowledge gap.
Some ideas for improvements:
- Add an example of how to convert input position to the coordinate system of a simple 2D scene.
- Add a table with on both axis a few common coordinates (eg input_event.position, node_2d.position, control.position) and how to convert to every other coordinate.
- Improve the monster chart to be clearer on what functions to call from where to get to the other coordinate.
- …
URL to the documentation page:
- Godot 2D coordinate systems: https://docs.godotengine.org/en/stable/engine_details/architecture/2d_coordinate_systems.html#godot-2d-coordinate-systems
- Viewport and canvas transforms: https://docs.godotengine.org/en/stable/tutorials/2d/2d_transforms.html#transform-order
- Mouse and input coordinates: https://docs.godotengine.org/en/stable/tutorials/inputs/mouse_and_input_coordinates.html
