How can I get a 3d object to always face player/camera?

###There are two solutions I can think of and which one to use depends on what sort of label you want. I will do the most likely and easiest case first.

Widget 2D image dropped on top of the player’s viewport at the right spot:

###If your goal is to really label something for the player as a part of the user interface this is what you want.

Use the “Project World Location To Screen” function to take a location vector in world space and match it to a location on screen.

308218-first.png

NOTE: Deciding whether to put this in the Event Tick of the UMG widget blueprint or somewhere else would depend on the game. You would have to ask what makes the most elegant solution for your application. Obviously if it was a mechanic that worked for a certain type of pawn or game mode you would not want to put in (for example) the level blueprint.

A floating “billboard” static mesh that will exist in 3D space

If a widget will not get the job done or you want to go for simple weird/fancy (but possibly look pretty cool) you could have something that is a label but also a part of the 3D world. BUT you should keep in mind what this means…

  • Any other object could occlude/block it from view.
  • The detail visible (and readability of any text) would depend on distance.
  • Depending on the game/application it will appear somewhat “unnatural” as it is affected by lighting but looks the same from any angle. Unless someone was looking at it carefully, the extra work you do could ironically make the graphics look less sophisticated. (But if it was a survival horror game there could be good opportunities to create a creepy atmosphere).

As FinalZer0 noted the best way to do this is the Kismet Math function “Find Look At Rotation” which takes two vectors and outputs a rotator that would point an object at the first location towards the second. Just hook it up to the EventTick and update the transform. You could also change the scale of the transform as well on the Event Tick if you really wanted it to appear the same at any distance.

308219-second.png

2 Likes