Replicate Usernames in Widget Component above my Character
Hey Community <3 I came across a problem, I'm working on a fast paced game and I need names to show above the characters. Now i got HP bars that replicate perfectly and I scripted them inside the Actor, they share the same widget component as the usernames, however with this method both client and server see the same name above everyone. After that i tried couple of options but I just ended up with using player state which shows generated names that replicate correctly so server and client can see their names, but i want my clients to have their own usernames instead of randomly generated ones.
Here is a screenshot of my actual situation This one has generated names:
and this is with players own username:
I got it working after i don't know how many hours of testing each possibility. Thanks everyone for trying to help out. since i love unreal and it's community I will be sharing my solution thats still kinda confuse me, but it works lol So since i saw Server was able to see both usernames and client couldn't i switched back to the working system with generated names that you can see on the screenshot i posted before. I made some changes and i went crazy on that running the blood in my veins at 140BPM with high volume music. And i tought ok let's work on the custom playerstate again
NOTE: Each delay is necessary or otherwise this won't work this was the biggest problem in my script. Also be sure to set everything on reliable.
So thats what my custom Player State looks like, This changes the Generated Username to Custom One's but this wasn't enough alone to make all works.
Now thats all you need in your Character BP, be sure all it's replicated even the components!
Let's go to the Lobby Player Controller, this is a bit messy since i have a lot of Events inside But all you have to do is create a Custom Event On Server and reliable and connect the rest as you there.
For your widget just set this basic and simple bind. Always be sure it's replicated ofcourse.
And finally it should now works.
(it's 7.27 am now and i really need to sleep sorry for bad english or any misstyped stuff. I'm really happy i managed to fix that)
answered Mar 25 '18 at 05:50 AM
where are they accessing the usernames from? i think they are accessing from a save file or player controller and thus they are having the same username. If u try they in different pcs this wont happen if u still have problems join my discord at https://www.decodestudios.in
answered Mar 24 '18 at 02:31 AM
Hi. In my case, I'm using player name for chat game. Player have to log in to join the server so I'm storing their name into the GameInstance BP and on BeginPlay inside the PlayerCharacter BP you can get their name always in the GameInstance BP. save it into you character BP and use it like you want.
answered Mar 25 '18 at 01:11 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here