I'm trying to display text above an object, like a player's name floating over their head.<br>I tried to instance a Label and make it a child of the target's head mesh, but it didn't work how I expected.<br>Wondering if anyone had any suggestions, or already knows how.<br>
Display text above object
- Edited
"Didn't work" as expected? You need to elaborate or this will just be a guessing game.<br><br>Since I have no idea how you have setup your player nodes; I am going to write how you can add a label.<br>I assume this is done from code, since you wrote "instance a label".<br><br>1. Get node reference of your head<br>2. Create a label instance<br>3. Add label instance as child of head node<br>4. Change position to where you want the name tag to be<br><br>Example of how it would look without repositioning the label:<br><img alt="" src="https://i.imgur.com/nMl79AB.png" title="Image: https://i.imgur.com/nMl79AB.png"><br><br><br>Wherever the head moves; the label goes with it. If you rotate the head, the label will also rotate, so be aware.<br><br>EDIT: I noticed you posted this in 3D category. <br>I believe there is another node you can use in 3D for showing labels in 3D space (without having to resize and calculate distance from camera to the player you are looking it), but I am not sure - I do not use 3D in Godot. Although the principle should be same: Just make sure to use the appropriate node! <br><br>
- Edited
This is in the 3D category because the game is 3D. If you add a 2D node to a 3D, the editor stays in 2D when you select the 2D Node. So I can't just place it in the proper 3D location. I would have to "guess" where I am placing it for every different object. Thanks for the suggestion, I am going to see if I can find that node.<br>
I tried the BitmapFont and DynamicFont class but with no success. However Sprite 3D produces the exact behavior I am trying to achieve, but is meant for textures. I saved some text as an image and it works. If I find a better working with font solution I will update this.
Please, do check the GUI_in_3D demo project that comes with Godot demo projects.
Thanks for suggestion Sakaki. However this is not what I am looking for. I want to use dynamic text to display a object's name floating above their heads.