How do I put text on a 3D scene?

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

I’m making a game in VR and I need some text but i coun’t find any node that can help?
I need some flat text editable from the Godot UI or by code.
Anyone know some solution?

:bust_in_silhouette: Reply From: Snail0259

Use a sprite3d

How, exactly?

DinDinDin | 2021-07-22 20:30

Sprite3D isused to display 2d pictures in 3d scene. I don’t thing you would by able to show the text using it. If you have the writing as png then it might work

Help me please | 2021-07-23 04:50

By using a ViewportTexture (with your text in a Viewport).

DinDinDin, sorry that it’s been a bit unclear.
Later on I’d like to give a proper answer for your question, but for now I have this project on Github, it is mostly irrelevant to the topic but it does have an example of a Sprite3D/Viewport text if you’d like to look into it:


Yuminous | 2021-07-23 05:46

Yep! it works great but also I think using viewport is good option for showing 3d health bars, levels of mob or anything else. But don’t think if it’s good for showing on UI. It would somewhat look like a blackboard (not really, just a comparison). That’s why I stated that.

Help me please | 2021-07-23 12:55

:bust_in_silhouette: Reply From: Calinou

See the 3D waypoints demo for an example of this.

Is my way (the way i suggested) good or do it needs any improvement?
I use to do this without any error but I am wondering is this the best way.

Help me please | 2021-07-23 04:46

Help me please, using your method is perfectly OK for static UI. I use that myself for all my menus, but the important distinction here is that even the nodes are “in a 3D scene,” you’re actually displaying a 2D scene over your 3D one. It’s still a 2D scene and it acts like one.

For “in-world” 3D text elements (such as name tags), you would want the text to act like a 3D element by being anchored to a certain point in 3D space. You can estimate this point through the use of camera raycasting with Spatial node, essentially what Callinou was suggesting with the “3D Waypoints” tutorial.

However, that isn’t the perfect solution either, as the text element will not resize at all, no matter how far it is from the camera (without scripting).
For this reason, the ultimate in-world solution text is to use a 3D Sprite with a Viewport texture as Snail0259 was trying to suggest but with only half of the essential details and no instructions. The 3D sprite is an actual 3D element and its display is very intuitive for the game designer.

I hope it’s somewhat informative!

Yuminous | 2021-07-23 05:34

I am 70% noob that’s why I don’t know much.

Thank you again for the information

Help me please | 2021-07-23 13:02

:bust_in_silhouette: Reply From: Help me please

You want to show 2d text in 3d environment?

The best way I know is:-

  1. Convert your spatial root to node.
  2. Then add a label to your scene.
  3. Set its position, scale, size in 2d editor.
  4. When you will run the scene you will find the label where you had set its position

Rather than label you can also use other control nodes to do so
I always use this way to display my UI in a 3D scene