Download

Accurately placing sprites over 3d models: screenspace or worldspace?

I’m trying to figure out the best-looking way to place 2d sprites and speech bubbles over the heads of my 3d characters, so it looks something like this:

I’ve come up with two ways to do it thus far, and both feel a little hacky: in both cases I add a scene component to the NPC’s blueprint, and manually position it above his or her head so that the system knows where to place the sprite. Once it’s there, I can either spawn a sprite in screen space and manually move it to the WorldToScreenSpace coordinates of my scene component. That looks decent, but there is noticeable lag every frame when I move the camera and the sprite needs to teleport to a new location.

Alternatively, I could place the experimental 3d UMG widget over the model’s head directly, and set it to the sprite I want. That would have the advantage of being easier to position and looking better during movement, but I would have to check every tick and rotate it to make sure it faces the camera correctly.

Is there a better way to accomplish this that I’m missing? My first option seems like the best thing I’ve come up with based purely on the fact that it doesn’t rely on an experimental feature, but neither option feels too great.

Why not just use UMG. In order to avoid widgets lagging, set the TickGroup of the object responsible for position tracking of the widgets to PostUpdate.
15aa9659a39c11b8d54883ee69e8c70c32b8b26d.png

Oh, I wasn’t aware of tick groups, I think that would very likely work swimmingly… am I on the right track by managing all icons from a central HUD management class, and simply messaging that class to add/delete icons from the classes that detect the need? (In this example, the current control flow would be player enters NPC’s proximity detector > NPC messages HUD with its reference and the icon to display HUD creates the sprite and moves it every tick.

It all depends on the complexity of your project. Being organised always pay off; I’ve been trying to keep track of all widgets from the HUD class but ended up cheating here and there.