How to fix a label to a Camera2D, so that it stays on screen?

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

First off, I’m a noob at this. A total noob who just attempted making his first game without help. Everything went fine, but now I want to make a speedometer for my Player - a rolling ball. My player is a RigidBody2D with a Sprite, a Camera2D and a CollisionShape2D as its children. The camera is set to be Current(follows the player) and it has some smoothing. How can I make a label that will stay on screen in a constant, fixed position(a corner of the screen preferably), and display the X linear velocity of the ball? If something’s unclear, just ask. I really need this help.
PS: Setting it as the child of the Camera will just make it spin with the ball.

:bust_in_silhouette: Reply From: volzhs

Add a CanvasLayer and put whatever you need.

And then, how can I make the label display the X linear velocity of the RigidBody2D? It constantly give me errors saying that the node can’t be found (after using $)

OskarnikPL | 2018-06-09 12:48

I tried

extends Label

func _process():

Didn’t work obviously, no errors but the text is blank

OskarnikPL | 2018-06-09 13:10

the code you wrote does not make sense.
why are you getting a “Label” node in Label (extends Label)?

CanvasLayer is more like another scene which is not affected by others.
so, you’d better to make a scene tree like below

- root node
    - your game node
    - CanvasLayer
        - put nodes those you need to control in another way (like stick to a fixed position)

volzhs | 2018-06-09 13:47