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"

Draw player HUD in multiplayer

Hi guys!

I'm a french student just trying to develop a simple multiplayer game. I want to draw a basic UMG (with a health) for each player. Variables such as life, armor etc are on my character's blueprint and are set to replicate. This character blueprint also have a GetHealthRatio function. I have a player controller which should initialize the widget and character reference and the widget reference. He also has to initialize the content of the widget and display it on the player's screen.

This is quite good but, even if the picture of the HUD is drawn, the health percent does not appear whereas it does in SP mode... I know I certainly did a mistake on authority setup (sorry i don't have the real good words...) and I hope you'll be able to give me some tips in order to solve my issue.

Here are my blueprints : alt text

alt text

alt text

alt text

alt text

Product Version: UE 4.12
more ▼

asked Sep 21 '16 at 12:42 PM in Blueprint Scripting

avatar image

1 1 2 2

avatar image Koralgoll Sep 21 '16 at 05:38 PM

It is quite hard to tell what is wrong when we are talking about muliplayer. Make sure you enabled replication for Actor were you are going to replicate variables (Class Defaults -> Section Replication -> Replicates). Be careful of using Get Player Character from Player Index. In multiplayer it may return Server-version of the Character when it it will be called by Server.

avatar image MrAlexan14 Sep 21 '16 at 07:10 PM

First of all, i verified if the PlayerCharacter was replicated and the Replicates checkbox is well checked. Variables are replicated too.

So you tell me to be careful using GetPlayerCharacter from PlayerIndex, but I don't know how to do it properly... I read somethings about GetOwner which returns an Actor and that I linked to CastToPlayerCharacter in CreateWidgetAndReferences. And it still doesn't work.

Here is my error log :

Error Blueprint Runtime Error: Accessed None trying to read property CurrentCharacter from function: 'InitWidgetContents' from node: Get Health Ratio in graph: InitWidgetContents in object: MyPlayerController with description: Accessed None trying to read property CurrentCharacter

I've it as many as I have players.

I guess I've a problem in initialisation or in networking.

avatar image Shadowriver Sep 22 '16 at 01:47 AM

"None" in blueprints is "null", so "Accessed None" means you trying to call function on from null (blue link connected to "Target" pin is None)

My guess is you doing wrong cast, UMG widget is owned by PlayerController not Character or Pawn, you can get those from PlayerController

avatar image MrAlexan14 Sep 23 '16 at 05:57 AM

Isn't it what I am doing ? I get the GameHUDWidgetRef from the PlayerController as far as I know. Did I misunderstood you ?

avatar image Koralgoll Sep 22 '16 at 09:16 AM

Try to Get All Actors Of Class and check returned array for any Characters. If you have one Client connected you can get the first element from array and try to call function this way.

avatar image MrAlexan14 Sep 23 '16 at 05:58 AM

Thanks for your answers that might be good but I don't understand or I don't know what do you mean by "Get All Actors Of Class". Do you mean get All Player Controllers instances ? If so, how can I do it ?

avatar image Koralgoll Sep 23 '16 at 09:50 AM

In place where you want to use your Current Character, call Get All Actors Of Class (set class of your Character) and check if length of returned array is > 0. If there are Actors in the array and your variable is still None, that means there is a problem with initialization of Current Character. But still you can use "Get" function for this array and this will return your Character if there is any.

avatar image MrAlexan14 Sep 23 '16 at 06:55 PM

Thanks for your answer. I tried just what you told me: replacing Current Character (in my PlayerController Blueprint) and it works on a way... In fact, I do not know how to get the good player via the Get All Actors Of Class? How can I get a Current Character reference via this array

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

1 answer: sort voted first

I do not know what the problem is, but I would recommend check this tutorial if you have not already, it will give you great insight on multiplayer systems in UE4: https://www.youtube.com/playlist?list=PLZlv_N0_O1gYqSlbGQVKsRg6fpxWndZqZ

more ▼

answered Sep 23 '16 at 06:37 AM

avatar image

Night Watcher
1.7k 44 12 71

(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