Rotate a text around Z axis using "Align Mesh To The Camera"

Hi!

I’m using Unreal 5.0.3.

I want to make a Text Render Component that faces always to the camera. I have used this:

But the text rotates around X axis or Y axis while I rotate the camera around the character:

But here it works perfectly:

How can I solve this?

1 Like

To solve this issue with UE4.27 we use a “widget component” and in the parameter of the “user interface” we set “space” = “screen” instead of “world” and the widget is automatically facing the camera.

Thanks. I’ll try it, but I’m using Unreal 5.0.3 and a Text Render Component.

In a “widget component” you can put what you want.

The question is about a Material, not about a “widget component”. Thanks.

I think you’d have a lot more ease if you did the rotation in the player, and not the material.

A text component or widget component. Either would do.

text rotation

1 Like

Hi, here’s what you are looking for, hopefully.

image

@ClockworkOcean tick solution is ok, but so much heavier than shader.

4 Likes

Tick is not evil, if you use it correctly…

Yeah, but rotating a component with tick is much heavier than rotatnig pixels with material, even in c++. It may be less convinient in some cases, but not in this one really.

Actually, I love this material a lot as I use it for dev purposes, like describing my trigger boxes and stuff, this way it always faces my camera, even if I’m not playing. I strongly recommend it for level readability :slight_smile:

2 Likes

Align mesh to camera is also Evil.
double-click into it and learn how it works.
Re-create it in the material with just Rotate About Axis.

Rotation Axis = Object Orientation
Rotation Angle = Math
Rotation Pivot = 0,0,0 - unless you need to move the pivot to the bottom of the text, in which case - 0,0,-height of text.
Position = Absolute world position including material offsets

For angle math.
You should probably open the C++ function to read if the value to be fed is in radians or degrees.
Either way, SOCATHOA the angle from object position, to camera position.

(nodes here
Coordinates Material Expressions in Unreal Engine | Unreal Engine 5.1 Documentation)

PS:
Isn’t there a RotateAboutAxis_cheap node in the pre-made functions anymore?
IF there is, try learning off of that.

2 Likes

@lordlolek Thanks a lot, but it doesn’t work for me. I get the same result than mine.

Thanks.

It works in a single player game, but it doesn’t in a multiplayer game:

1 Like

The tick solution will have no impact on your game, unless you have like > 250 players… :slight_smile:

Sorry, I haven’t explained well. Both names need to face to the camera for the current player.

In the image that I’ve pasted, I’m playing with the player “Servidor”, and I can’t see the name of the other player.

I need to both names face to the camera of the current player.

Sorry, I thought it was clear from the picture.

2 Likes

ah - totally different thing. Bit of a pig, maybe…

I found this article about to do it in a multiplayer game: UE4 – Network, player name labels. – Selbryn

But I don’t understand what he did.

You basically need a version of all character’s names for each character. In short, doing it in the material isn’t an option.

What? Why?
The material will always work local to the Camera and the Object. It’s the perfect candidate to have each client’s text rotate to face the camera.

Conversely, to do it via tick you need to set up a tag manager that is in charge of orientation calculation on a per-client basis. So that only the current client’s camera is taken into account and the rotation is not replicated.

1 Like

You’re right :slight_smile: ( but it is strange the material doesn’t work, I mean, a camera is a camera )…

If he is using the material method and getting that result, then maybe the material is being replicated across the network… it shouldnt be, but its the only thing I can think of…

1 Like