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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Character widget component healthbar/Playername Replication

I have an issue replicating player name on my custom health bar. iv made a simple project using the player ID as name, each player have their own unique playerID Server=0 Client1=1. Using print string I get Server=0 and Client=1 as expected but when I try to show my variable (PlayerID) from the player controller It doesn't work correctly, on the server I see PlayerID=0 and I see the client with PlayerID=0. On the client side I see the server with PlayerID=1 and the client itself with PlayerID=1. How to show correctly the PlayerID on client and server? Here is the Link to download the sample project: https://drive.google.com/open?id=10Rz32dsaqiUGnYTXJiNKWHLFMTOVueNw Here are some picture of the blueprints and result;alt text

Product Version: UE 4.19
gamemode.png (182.2 kB)
result.png (439.4 kB)
more ▼

asked Aug 01 '18 at 02:40 AM in Blueprint Scripting

avatar image

19 3 2 7

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

1 answer: sort voted first

PlayerControllers only exists in server and they are replicated only to each owning client. That means that server has all player controllers. Client 1 has player 1 player controller only. Client 2 has player 2 player controller only, etc.

All the information about the players that you want to be replicated and known to all clients you should put it on PlayerState instead of PlayerController.

PlayerState even has built-in replicated player id functionality. You do not need custom classes for that to work.

Example with your project:

Just change your character begin play to this:

alt text

Custom GameMode and PlayerController logic is not needed for it to work.

If you do not like the default unique player id in playerstate create your own as you did in your project but instead of putting it inside the PlayerController put it inside the PlayerState.

PlayerState has also built-in PlayerName. If you use that it will be set to your Steam user name if you run your game with Steam.

Hope this solves your problem!

more ▼

answered Aug 01 '18 at 03:10 AM

avatar image

1k 8 24 26

avatar image brahoule Aug 01 '18 at 04:11 AM

Thanks for your reply! I have one last question, I never used player state before so how to use my custom player id in player state? Can you show me a blueprint example?

avatar image brahoule Aug 01 '18 at 04:22 AM

Thank you very much! Just playing around with the player state and I figured out how to do it. Now it work as it should!

avatar image Sveitar Aug 01 '18 at 04:33 AM

I'm glad! Don't forget to mark my answer as correct so other people in the same situation can look for the solution.

Have a nice day!

(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