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"

c++ compare distance between players

I was wondering if there is a way to get distances between players in multiplayer so I can use it to set the scale the player healthbar? The healthbar is set as screen space and i want to scale it down relative to the distance between players.

Product Version: UE 4.19
more ▼

asked Aug 29 '18 at 10:13 PM in C++ Programming

avatar image

19 3 2 7

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

1 answer: sort voted first

I think it doesn't matter whether it is multiplayer. Just Subtract the Location of the player's Camera from the Location of the healthbar or the pawn it's following, and then get the Length of the resulting difference vector, and that will tell you how many Unreal Units of distance away it is.

well, maybe it DOES matter whether it is multiplayer because then you can't scale a healthbar toward one player and then hope it looks good to all the other players.

I don't know the best approach for this but what I decided to do was to for each Pawn, create a healthbar for each player that is on the local machine (so this thing I'm doing only runs on each client), and then setting its owner to the player that will be viewing it (not to the player it's describing the health of), so I can set OnlyOwnerSee to true on that healthbar. So each pawn has a healthbar following it around for one of the other players, and another for another player, etc. Then you can scale each one individually.

more ▼

answered Dec 04 '18 at 12:00 AM

avatar image

3.8k 18 20 20

(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