0 votes

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.

in Engine by (12 points)

1 Answer

+1 vote

Add a CanvasLayer and put whatever you need.

by (9,686 points)

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 $)

I tried

extends Label

func _process():
    get_node("Label").set_text(str(get_node("Label").get_linear_velocity()))

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

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)
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.