x

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 set up correct Widgets for multiplayer?

Hi! I'm currently working on a multiplayer game and I've tried to setup a widget with a health bar. Everything works correctly when I launch the game in a new editor window both on the client and on the server until the respawn happens. (Player dies, I press a button to respawn the player at a location of a PlayerStart) For some reasons the widget does not initialize. alt text

I think I messed up the Widget Blueprint, especially the casting part, because after the respawn I get tons of error messages about failed casting.

alt text

Here is the custom made player controller that creates the widget and then adds it to the viewport. alt text

Lastly, the simple setup for the health bar. alt text

I hope some can help me. I'm lokking forward for the replies. :)

Product Version: UE 4.15
Tags:
hp_inaction.jpg (119.0 kB)
widget_bp.jpg (159.4 kB)
hp_bar.jpg (490.7 kB)
more ▼

asked Mar 12 '17 at 10:33 AM in Blueprint Scripting

avatar image

ltamas97
8 1 3 6

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

1 answer: sort voted first

It would help if you show the code of the "RespawnPlayer" function.

Have you checked if the health bar work correctly on both sides? When you get an "Accessed None" error, from the "Add to Viewport" function you need to check if the player controller is a "Local Player Controller", otherwise the "Create Widget" function will return None for every client.

Then you can leave out the "Switch has Authority" and "Is GameMode Valid" nodes, because the "Request Respawn" function will only be executed on the server.

Instead of having a "Character" variable in your main widget, you can use the, "Get Player Pawn" function, the player controller at index 0 is always the locally controlled one, this way you can make sure there is nothing wrong during initialization.

more ▼

answered Mar 12 '17 at 05:50 PM

avatar image

SteffM
432 12 4 22

avatar image ltamas97 Mar 13 '17 at 04:57 PM

Hi! Thank you for your reply, with your help the widget works as I wanted. Thank you so much.

(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