Download

A text that always rendered facing the camera

Hi!
I want to make a text which will float above the actor. It must always face the player’s camera, it shouldn’t be visible through the level geometry. Also it should preferably be independent of distance (always the same size). It can be used various ways including NPC name display, damage numbers, dialog subtitle bars etc.

This blueprint does pretty much everything I need except it’s not independent of distance and also it gets affected by post processing (especially by annoying blur effect). HUD example objective text is seen through obstacles which is unacceptable.

test.png

Any thoughts of improving/other ways to accomplish this? (C++ is fine too)

You could use a trace node to trace from the text to the player.

The trace will also let you control visibility.

This will give you the correct rotation to feed back into the text.

I’m not sure on the scale though, maybe base it of the distance between the player and the actor?

Wait, where is the trace node located, is it a blueprint component? Also it still be affected by effects right?

Search for trace in the palette of the graph mode, and you see a bunch of them. You can read about them in the Docs if you need to.

It’s a blueprint component, there are a few of them.

The “Single line trace for objects” does what i’m talking about. You will also want to “Break Hit results”

As an aside the UE4 devs just released this blueprint tut that uses this very node for a different purpose.

Hope that helps!

traceNode.jpg

To correct, those are not components, blueprint components are the ones that you can add in the components tab. The ones you use in the graph are generally called nodes, but these (traces) in particular are more specifically functions.

I’ve made a font material which makes text face always to camera. Material set to ‘unlit’.

My font material:
text_material.png

Result:
result.png

Now looking at ‘ConstantScalebyDistance’ I would say that it can be used to make text always the same size. But how?

Were you ever able to figure this out? How can the material control the scale?

My desire is to have a min and max scale by distance on the text, where the closer you are the text stops scaling up and locks to a fixed max size, and when you are further away the text stops scaling down and locks to a fixed min size.

Can’t find any examples using this node. Seems promising though.

Hi, You can control the scale by this way:
constScale.png

Hi antondoe,

Could you please provide a few more details as to how you achieved the constant scale? I don’t seem to be able to implement it.

Thank you for you help! :smiley:

Edit: I managed to implement the scaling by updating the scale in code every tick. I’m still curious about the way to do it in the material.

Hi, sorry for late reply. this trick works for planes, that aligned to camera. it’s good for text. but doesn’t work for complex meshes. the idea beside is to offset each vertex in vertex pass towards a camera to make it be always on same distance to screen

You might find this useful (dropdown world->screen) - a widget component can be set to render in screen space:

22b4c04c9597edc4deb46f1a9414383f09d9227b.png

Geez, i totally overlooked that option. Thanks !

@fpcompany great idea, but have you tried rotating base actor around Z axis in the world? It makes text go upside-down at 180 degrees.

Hi there
Sorry for not being able to answer for so long, havent log in for awhile
First, I now use the ‘3d widget’ with text inside to display NPC names because it does not get affected by post processing, lighting etc.
Next, on actor’s tick I set widget’s world rotation to camera’s world rotation and then I add local z-180 degrees.