Player State replication not working

Hi !

I’m not sure to understand how the replication of the player state works. Well I was “understanding it” before I tried, be now after 5 hours of frustration I’m not so sure I understand!

I stored the player score in a custom player state. I’m then accessing all the player state from the game state ( “PlayerArray” ). Up to there everything works fine, but when I access my “ScoreData”, it’s always empty on the client side, but not on the server side.

So, this is how I initialize the ScoreData ( in the player state itself ) :

Then if I try to access the ScoreData from the server it works. But not in the client. To test it, I added a print in the character ( not the controller ). So the character get its player state, and print the “display name” of the score data :

There’s the result :

Everything works fine on the server side… If I kill someone from the server, it’ll show up in the score on the server side. If I kill someone on the client side, It will show up in the server side score ( in the widget ).
But I can’t get the widget to show up on the client side, because the ScoreData is always null… To add the “kill and dead” numbers to the score when a character is killed, I access the player state ( using GetPlayerState on the PlayerCharacter ). The only difference is I’m on the server side, but it’s suppose to be replicated… ( And yes, the “ScoreData” is set to replicate :slight_smile: )

This was the part I thought was the most “weird”. But in fact the problem is when i’m trying to access the data from a widget on client side ( not from the character )

The “ScoreData” in the Player State is null after the cast… It’s the same behavior here, If I print when In the server it show two “ScoreData” “DisplayName”, but when I hit tab on the client side, it shows nothing ( the ScoreData is null )

Anyone know what I’m doing wrong ?

Thanks! :slight_smile:

Edit :

I forgot to say, I’m not using a dedicated server :slight_smile:

Hi!

I found that the problem is that I am trying to replicate a custom Blueprint Object class. I did this simple test :

When I print string the “Score Data”, it print two value on the server but two empty string on the client
And when I print the boolean “Test”, it correctly print “True”, that was set on the serveur, on both the server and the client…

So now I’m wondering if it is even possible to replicate my custom Blueprint Object class ?

Thanks!

Under the replication tab (should be located in the list of tabs on the right side) on your blueprint for your custom class, there should be a “Replicates” check box. Make sure that is checked.

Hi!
Thanks for the answer, but I already looked a thousand time!

Seems like there are no “Replication” tab :

I did it entirely with a structure as it seems to be working. But I’m already starting to store other data ( for the tool bar now… ) and it is really frustrating to, not be able to encapsulate functions and variables in an object… The best I can do is put variables in a structure but it doesn’t looks really clean

Thanks :slight_smile:

You can’t replicate Objects :stuck_out_tongue: Actor is the first class that replicates.

You could replicate the Objects with C++ as Subobjects, but in Blueprints you can only replicate Actors and their Children.

Instead of an Objects, you could use a Component. They can replicate.

Oh… That’s not clear, I can set the object variables to “Replicate”… The option should be removed on the variables if the entire object can’t be replicated!
Well, at least I won’t make the mistake again :slight_smile:

Thanks!