+1 vote

How do I make a label follow the position of a KinematicBody2D but not it's rotation. That way the label is on top of the body and follows it around on screen, but doesn't rotate with it?

I achieved this one way by using this hierarchy:


However I had to copy the global position from the body to the node2D; is there a way to do it with this hierarchy?


Do I need an extra node between the body and label?

in Engine by (259 points)

1 Answer

0 votes
Best answer

You can put this on the Label:

func _process(delta):
    global_rotation = 0
by (21,712 points)
selected by

rotation and global_rotation are not properties of Label, so can't do that.

EDIT: However... can change the hierarchy to the following:


and set the global_rotation on the Node2D - *that* works!

Sorry, stick the Label to a Node2D first - I left that part out.

You can see an example of this in action for unit healthbars here:

Note, you can use set_rotation() in Control nodes, but that's a bit more hassle, I find.

I note that process works better than _physicsprocess which has a slight but noticeable lag.

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 Frequently asked questions and 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 [email protected] with your username.