Draggable/zoomable map within a control

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Calebe

Hello there! I’m new to Godot. I’ve been struggling with Controls for a few weeks now.

I’ve read the docs, a few assorted tutorials, browsed this forum and Reddit – but I can’t for the life of me develop a draggable/zoomable map by code/GDScript.

The map should have three layers. One for the lettering (should translate, not rescale); one for the UI (such as zoom in/out; fixed); and one for the map’s graphical elements themselves (should translate and rescale).

Could anyone please suggest me a node structure so I can accomplish this? Or point me to a working example project?

I already several combinations of Layers, Viewports, ViewportContainers, Camera2Ds, but nothing seems to work… and when they do, it’s in unexpected and automagical ways.

Thanks.

:bust_in_silhouette: Reply From: aXu_AP

I think this kind of hierarchy should work. Place labels with the help of Node2Ds. You need to have script for text container nodes that counteracts zoom of the Camera2D. I think using 1 / zoom as a scale should do the thing.


As to how one would do draggable and zoomable camera, I found an article of it.

I’m a bit… worn out by Godot at the moment, so I don’t really have the energy to test this out, but eventually I will. But really, much obliged for the answer!

Calebe | 2021-05-03 13:20