Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to make a widget blueprint that shows enemy/team icons over other players.

alt text

Product Version: UE 4.8
01-014_opt.jpeg (671.3 kB)
more ▼

asked Jul 01 '15 at 12:02 PM in Using UE4

avatar image

20 5 9 11

avatar image Taurian Jan 13 '16 at 01:06 AM
  • Is drawing the icon every from in the Hud class the only option?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

There are 2 ways to make this happen.

  1. Experimental 3D widgets. IMO worse option - they may be drastically rewritten with each next patch, they're heavier I believe as well.

  2. Create a regular widget that looks the way you want. I describe it below.

Assign some offset from the player position to display the widget above (typically X and Y are 0, Z is somewhat higher, around 100 could be a good start, but depends on your project scale). Then in the HUD class iterate through all the positions that are in the view range (take each, project to screen space, compare against your window size, you can safely cut out all that have either X or Y negative). Then simply set position of the widget to the one you found and fill the relevant data you want there (health, nickname etc.)

This is obviously just a first step, but once you do that you'll have it working, I've done something similar few months ago. What you could do next, and probably will is:

Center the widget. By setting the position to your pawn position + offset you'll make it draw the left corner there and the widget will look moved to the right. Calculate the widget width and height, get the middle point and offset again to make the point you choose. You may also just move the previous offset so it 'more or less' looks ok.

You have to create widgets on demand, because more players may show up on the screen. Having stored 100 widgets with 90 not used is a bad idea. Spawning them each tick is bad as well. You would need to store those already done and add more on demand. There are several solutions to this - you can add more if you have less available and keep them to not fragment the memory for example, but there would also need to be some boundary conditions. Might get tricky here, so start with simple.

Then there's the updating of widgets - visible player may get damaged thus forcing the update on health bar. For simplicity you can just set it each tick, but if there are many variables, you may want to check whether an update is needed or not. The widget itself may have a pawn assigned and as long as it is not NONE set it's own variables (each tick or not, each tick is simpler). HUD class doesn't have to do this. Doesn't need to know, even.

Depending on what you want, you may also want to have the widget shown when the player is off-screen, but the widget would be visible. Such case can be also calculated and simply widget rendered with it's left corner off-screen, the visible part will show up. Whether it's something you want or not is up to you.

The task is bigger than several screenshots would cover, but the simplest version - iterate through every player, assign widget, set position and data - is pretty simple.

more ▼

answered Jan 13 '16 at 09:05 AM

avatar image

379 14 10 25

avatar image YouE4 Jan 24 '16 at 10:26 AM

Can you show me the simplest way to do this?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question