2
\$\begingroup\$

I have an actor (Minion) with a Text Render just above it mesh:

enter image description here

As you have seen, I defined your rotation as absolute, so the text does not rotate along with the actor.

In the game the rotation setting is good and acceptable at various times:

enter image description here

At other times it is very bad:

enter image description here

An example of what I want is something like the life of the champions in the League of Legends:

enter image description here

I would also like to know how to do this when I am simulating:

enter image description here

I've made some attempts at the camera of my main character. And I got some of what I tried.

Character Blueprint:

enter image description here

I know I could put on the Event Begin Play because the camera does not rotate.

Minion Blueprint:

enter image description here

I did (partially):

enter image description here

Ignoring the fact that the text is inverted. I tried Split Struct and added 180 to each of the 3 axes (ROLL, PITCH, YAW) and I could not solve it anyway.

Simulating nothing works:

enter image description here


EDIT 1 (Attempt made based on a_rrat's answer)

Blueprint:

enter image description here

I think I tried all the combinations and none worked the way I would. The combination defined in the image made the Text Render spin.


EDIT 2 (Correction of the attempt I made wrongly)

Correction that I did:

enter image description here

With the answer I was given I noticed a marked improvement.

Result 1:

enter image description here

Besides the value is no longer inverted.

Result 2:

enter image description here

But I still have not got what I like.

Result I am looking for:

enter image description here

I wish life would be displayed the same way anywhere on the map the character is on.


EDIT 3 (Removing roll)

Blueprint:

enter image description here

In game there was no difference.


EDIT 4 (Trying to explain what I want to happen)

I think that because I can not speak English and have to use programs to translate things for myself, I do not know the best way to explain my doubts, the best words, among other things.

I think the best way then to try to explain what I want is with images.

I want regardless of the location or angle life is seen in the same way.

Image:

enter image description here

Image:

enter image description here

Image:

enter image description here

In the LEAGUE OF LEGENDS anywhere on the screen that the champion is, the life bar appears the same way. I would like to achieve this result.

\$\endgroup\$

5 Answers 5

2
\$\begingroup\$

What's happening here is two things :

  1. You are just applying the camera rotation to the text instead of billboarding the text
  2. You are rotating all the axes of your text, when you need to rotate it on one axis only

    What you can do instead :

\$\endgroup\$
13
  • \$\begingroup\$ I clarified in the issue I made. I did not modify the 3 axes at one time, but one at a time. After 2 in 2 and also the 3 at once. No combination worked. \$\endgroup\$ Jun 17, 2019 at 3:45
  • 1
    \$\begingroup\$ Have you tried using the technique suggested instad of applying the camera rotation directly to your text? \$\endgroup\$
    – alpha_rats
    Jun 17, 2019 at 4:56
  • 1
    \$\begingroup\$ You have a BP node specifically for that FindLookAtRotation, where you pass the text WorldLocation and CameraLocation (as goal) this node returns you a rotator which you should apply to the TextMesh. \$\endgroup\$ Jun 17, 2019 at 23:08
  • 1
    \$\begingroup\$ In your question - what did you plug in to FindLookAtRotation target node ? It doesnt look like a camera’s world location. \$\endgroup\$ Jun 18, 2019 at 0:22
  • 2
    \$\begingroup\$ @BonecoSinforoso what you did so far is getting the rotation of the camera and applying it to the text - what you should do is to get a direction (vector) from the text to the camera, and use this to determine the text rotation \$\endgroup\$
    – alpha_rats
    Jun 18, 2019 at 12:56
2
\$\begingroup\$

To make this work in the same way as your League of Legends example, you need to put a Text inside a Widget component which is attached to your character, not TextRender.

The reason for this is that you can set the Widget to display at the same location in world or screen space so it moves with the character and does so automatically with rotation.

Create a Widget as you normally would by going to Add New -> User Interface -> Widget Blueprint

Create Widget Blueprint UE4 image

Drag a Text component onto the canvas, use the font options on the right hand side to get it the size you want, set the Anchor in the middle then shrink the canvas size to match the text.

IMPORTANT! Make a note of the size X and size Y of your Text component.

Set Text Component to Size on Widget UE4

Now go into your character and add a Widget component to it.

Add Widget to Player Character UE4

In the details tab, under User Interface, change the Draw Size to that of your text component and make the WidgetClass the name of your created Widget.

Amend Widget Class Details Player Character UE4

Move the widget around as necessary to get it above the character as you wish. If it's a third person character, you may also need to set the rotation to 180°.

Finally, under User Interface, change the Space setting from World to Screen. This will make the widget disappear from the blueprint (though you can always change it back if you need to make adjustments) but when you play, it will be with the character in the same location at all times.

Final Result of Widget to Character UE4

Using this method will make the widget appear exactly behind the character. If you want to have it rotate with the character, you need to get the default Z rotation of the character (270° in the Third Person character) and the default of your widget (180° in my example) and calculate the difference per tick.

Widget With Rotation on Character UE4

This will now always display with the front of the text, no matter the rotation of the character on screen.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for your answer. In edit 4 of the question I think I can explain exactly my desire. \$\endgroup\$ Jun 19, 2019 at 23:53
  • \$\begingroup\$ @BonecoSinforoso See my last paragraph about using tick to rotate the widget component. \$\endgroup\$
    – Stephen
    Jun 21, 2019 at 10:37
  • \$\begingroup\$ Yes, I managed to make it static, but the 2 other axes are not the way I would like it. \$\endgroup\$ Jun 21, 2019 at 21:24
2
\$\begingroup\$

This was years ago but I wanted to add in, for anyone curious and struggling like me, how I did this.

You set the world rotation of the component in question to the value of your camera's rotations as follows. Get the PlayerCameraManager, get Camera Rotation, and break out the rotator. You're going to make a rotator for your SetWorldRotation pin and input

X, Y * -1.0, Z + 180

From camera rotation.

This image shows what I mean. The blue line is mean turning this into a Quat and back to a rotator, just incase gimbal lock messes with this at all. enter image description here

\$\endgroup\$
1
\$\begingroup\$
  • Firstly create a Widget Blueprint with custom size.

enter image description here

  • Remember the size you set.

  • Preferably place the text size equal to that of the widget.

  • Add the widget component to your actor.

  • In the Space option, select screen.

  • In the Widget Class option, select the widget that you created

  • In the Size option, place the same one you placed in the widget.

enter image description here

Results:

enter image description here

\$\endgroup\$
0
\$\begingroup\$

Most simple algorithm for understanding is just get ForwardVector, then multiply it my -1.0f and convert to Rotator. In C++ it's like FRotator NeedRotator = (Camera->GetActorForwardVector() * -1.0f).Rotation();

\$\endgroup\$
1
  • \$\begingroup\$ How would that be with blueprints? \$\endgroup\$ Dec 1, 2021 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .