Maintaining text size regardless of camera zoom (in 2D)

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

I’d like to keep my Labels displaying text always at the same size, regardless of zoom level.

I have a camera that zooms in/out with the mouse wheel. And I also have numbers popping all over the map to indicate damage taken and such. However, once you start zooming the text becomes blurry, and at extreme zoom levels, unreadable.
I mention this because if the only solution is using a CanvasLayer, I still need to keep the Labels positioned in the map (world space).

I’ve already tried all the Mode and Stretch proyect settings combos, to no avail.

Any ideas? Thanks!

:bust_in_silhouette: Reply From: Pomelo

There might be better ways, maybe using some control nodes , but a quick fix would be to decrease the scale of the labels by the same amount of your camera zoom. Not sure if the amounts have the same meaning but yhea they probably have (since they both start at 1 and if you go 0.5 its half the original value).

Try this and let me know! label.scale.x = 1/camera.zoom.x (same with y)

This is so simple but it would totally work. Thanks!

For the record, you can change both axis in a single line of code:

label.scale = Vector.ONE / camera.zoom

bloqm | 2022-06-20 08:17

oh haha, great tip! glad it helped!

Pomelo | 2022-06-20 12:53

1.) But what is the Vector.ONE? and how do I get that?

  1. My problem is that my font is ugly without zooming

BekoSan19 | 2022-07-13 00:28