Download

Best way to do floating health bars for an MMO style game.

You know in MMOs where all players have a name and a health bar floating over their characters. I have followed the instructions from a few different people and have got the following results.

The problem is that all of the health bars seem to just float over my characters head rather than everyone having their own health bar. Now I tried to do this with making a widget component over top of the characters head and that seems ok but then I run into the text and bar not looking very crisp.

Also I am noting that there is a use of on tick event which is bad performance wise.

What is the best way to do this for an MMO style game?

below is the current blueprint setup where all of the health bars float over just character.

There is a post from Nick somewhere here that explains how to do floating stuff with UMG

I saw a few different sources and I have followed the directions closely. I am missing something though. But I cant figure out what. Why would they all float over just my head?

There is a widget component you can add to the character, versus adding the widget with an owning player like you posted above (this may still be an experimental feature which you have to unlock by selecting it in your editor options). However, to avoid the weird widget that moves when you move feature, you have to set the Health bar or whatever up without using the canvas component. This will allow the widget to move in the screen space relative to its owner. Also, I don’t believe the tick event stuff is required; maybe on some of the previous engine versions before the widget component but I haven’t used a tick event to pass update info. There is an issue with making it visible and not visible on characters using the widget component that I hope is fixed in 4.8; I haven’t checked recently. I am going to go back into a project tomorrow and check out some of this stuff. I’ll repost if I find out anything exact and maybe post some BPs.

I cant for the life of me find a widget component experimental option like you mentioned. I did however try adding the the widget as a component to the character and it works really well except for one problem. It loses its crispness and also seems to need to be rotated to the players screen every frame using an event tick. I guess you mention not using a canvas to avoid this problem?

However I do have the health bars functional now. The only issue with this is that event tick being updated every frame is atrocious performance wise.

Ill have to look into this a bit more to see if I can get a method that works well and doesn’t need event tick.

The widget component is experimental, there’s no option for it, just the nature of that component. We may change stuff about it, generally for the better, but the warning is there all the same that we may break backwards compatibility one day and you may need to fix up some stuff, but by all means use it.

The component defaults to rendering the widget in the world, aka on to a render target it then renders as part of the scene. For classic 2D UI in screen space, just change the “Space” property on the component to be Screen, instead of World.

Ok so it looks like its working really well and I can completely avoid the whole event tick using this method. One problem left. How do I center the pivot on the widget? I cant seem to get these name plates to sit directly over the players head.

The default pivot (0.5, 0.5) is center. What is the Draw size set to, still 300x300? If the widget you’re showing has a size box in it, or some other means of artificially limiting the size, you should change Draw Size to 0,0, that will cause it to draw at the desired size of the widget you’ve set in the component.

I dont see anything with the word size or draw in the variable name and it seems like nothing I do will properly align it. The above suggestion to get rid of any canvas panels also doesn’t seem possible as even if I delete the base one it just adds another one when I do anything. If I move the object around I can get it to appear in a more desirable location but the pivot ends up being completely screwed and it goes all kinds of weird from different angles.

I guess this being called experimental makes a lot of sense.

edit: There is a draw size if I add my own canvas panel. Problem with this is that setting those size variables to 0 0 makes the widget invisible.

edit: Yeah I am definitely missing something or there is just wonkyness due to it be experimental. Its all kinds of messed up right now when I look at it from different angles.

Draw Size is a property on the widget component. Adding or removing canvases doesn’t have anything to do with the problem at hand.

AH!

I found draw size on the widget component. It was 500x500. I changed it to 0x0

sigh it made the problem even worse. the bars are now floating way off in some random direction.

:confused:

There’s a bug in 4.8 with resolution scalability and widget projection, do you by chance have it at something other than 100%?

I haven’t changed anything for the scale. Looking over all scale options, they all seem to be at 1.0.

Ok one very big super important detail that was left out when using widgets on components as health bars over the players head.

These health bars behave VERY differently when you package the game vs testing in the editor. I am now using the health bars with the experimental widget component and it works really well but while testing in the editor they appear to be oriented very strangely. Once I package the game however they act exactly as they are supposed to act.

So in other words, what you see ain’t exactly what you get but what you wanted in the first place? :slight_smile:

Yes, but it only looks correct after packaging the game. During testing in the editor its all over the place.