+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?

asked Mar 23, 2016 in Engine by grol (94 points)

2 Answers

+5 votes
Best answer

Put your label as child in a CanvasLayer

answered Mar 23, 2016 by jospic (1,380 points)
selected Mar 24, 2016 by grol

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.

answered Mar 23, 2016 by Alex\doc (105 points)
edited Mar 23, 2016 by Bojidar Marinov

That worked. Thanks.

Hi!

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.