I’m following GameDevRaw’s multiplayer guide and I’m still working on the skeletal frameworks. I’m trying to display the players names in game.
As it stands right now they can carry from the main menu to the lobby, but get lost when traveling to the map. The tutorial uses seamless level transitioning, which I won’t need to use. So much of the blueprint comes from the tutorial, with a few change outs from me to try to get it to work without seamless.
I have a playerstate blueprint that simply has the Player Profile replicated. Attached are two photos of the blueprints, one of the game mode of me attempting to store the name to the player state’s player profile. The second is a snippet of the HUD blueprint attempting to call the stored variable from playerstate.
I can get the correct responses to print from gamemode, but am getting blanks from the HUD on load in. I’ve been messing around with it, looking up videos and trying to use chatgpt (it’s hit or miss, but great when it hits), but am so far coming up empty.
Thanks in advance to anyone who takes a stab at it!
Hey omegamajii! How are you?
I’ve been checking about this and something that could be happening is that the HUD is trying to access the info before it is set serverside.
I think something you could do to avoid that is to change the Replication setting for your Player Profile variable in your player state blueprint to “RepNotify”. This will create a new Function called “OnRep_PlayerProfile”. Then you can create an Event Dispatcher called “OnPlayerInfoUpdated” and call it inside that function.
After that, you should be able to bind to that event on the HUD blueprint, and get the names at the moment they are updated, avoiding any “none” response from the server.
If you need more help with that, please specify which part of the tutorial are you on (there are more than 120 videos in the playlist haha) so I can have a better context of the problem!
I appreciate you checking this out. The method before recognized that there were two players, but couldn’t get the names even though I attempted to set the text from the playerprofile breakout (printed "text is: " the number of times equal to the number of players, but nothing from the second print statement). I’ve put it together how you mentioned (at least, I think so). I’m still very new to the blue print system and how things pass back and forth so let me know if you see anything that seems off.
As for the videos, I’m on 6 and I think 4 and 6 would be the only really relevant ones.
Anyway, I adjusted S_PlayerProfile to be on rep. The first picture is the function created and it broke the for loops such that the "text is: " statement in the HUD never prints. I think it’s because it switches the variable from replicated to repnotify.
I store player credentials etc in a “Profile” slot in Save Game file.
Player Name and any other customization.
In your Player State class create a Variable for the Player Name.
Create a BP interface event that will set the player name.
Controller class…
Create an RPC “Set PlayerName” (player name) [Run on Server, Reliable]
Have this event get the playerstate and call the BPI Event.
When the client gets its controller have it load the Save Game (Profile).
Call Set PlayerName.
Make sure you only execute this for autonomous proxies.
Hello again!
Ok, what you are missing now is the part where you listen that event you have created. You need to bind to that event from the Player State in the HUD BP, and check the names when it triggers.
As you can see in the previous image, you need to access the Player State for each active player and then store the names. Once the loop is completed, you can use that array to update your HUD.
Please, let me know if it worked!
Thanks! I’ll take a look at this over the weekend when I’ve got a bit more time and let you know how it turns out!
1 Like