+1 vote

So many questions :).

I have a camera which is able to zoom in and out and i have a label which shows the amount of zoom. How can I prevent that the label is also getting zoomed.
I tried to use more nodes and nest everything in different ways but had no success so far.
Do i have to use a second camera with another viewport?

in Engine by (96 points)

2 Answers

+5 votes
Best answer

Put your label as child in a CanvasLayer

by (1,458 points)
selected by

This blocks the position but not the zoom. Or did I miss something?

No sorry. It also blocks the zoom. I only have to figure out what position it has relative to my viewport.

I noticed this was posted after the comment that you got it to work.

This worked for me: https://gist.github.com/groud/518598d2682725535c99feb0dfa77e9e

In the context of Escoria: https://github.com/godotengine/escoria/pull/224/files

Hope this is useful to someone facing the same problem!

0 votes

Assuming you are in 2D (I never tried 3D before)
I would add a function to the camera to return the zoom amount:

func get_zoom_amount():
  return get_zoom();

then I'd make a new parallaxBackground, check ignore zoom add the label as child.

On the label, add a script to set the text using the get_node("camera").get_zoom_amount() change it basing on the hierarchy.

by (109 points)
edited by

That worked. Thanks.


Would you be so kind as to share the code that made it work? I'm struggling with the exact same problem (in the Escoria framework) and help would be greatly appreciated!

I have tried both a CanvasLayer and a ParallaxBackground, but I don't understand from the reply what "setting the text using" or "changing 'it'" really means.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.