You probably want a scene just for that; call it "billboard_label
" or something, than copy the code available on the GUI_in_3D
demo. Basically, in this scene you'll have a Quad (with the Billboard option enabled, so the player will see the text orthogonally no matter the camera angle), a Viewport (with the Render target enabled), and a Label as a child of said Viewport. Then just add a script with the magic code:
get_node("area/quad").get_material_override().set_texture(FixedMaterial.PARAM_DIFFUSE, get_node("viewport").get_render_target_texture())
This will make your Quad render the label of your Viewport. You'll probably want some other methods on the billboard_label scene to make it more functional, like "set_billboard_text(string)
" to edit the Viewport label without having to access all the nodes 'from the outside'. Than finally, when you want your enemy to display the damage, just create your "billboard_label
" via script, set it's text, and animate it accordingly (probably by using a simple timer and queue_freeing()
by the end of it).