Hi everyone. I have a multiplayer setup. when the player logs in, after the post login in the game mode, I change some attributes of the player mesh (blendshapes, textures) using some variables that I passed from the lobby to server pawn using the game instance. The first player looks fine, when the second player logs in, the first player sees the correct attributes of the second player, but the second player sees the default attributes of the first player, not the correct ones.
The attributes are stored in the pawn as replicated. Can anyone help?
Thanks
The data types you are mentioning don’t support replication. For example, a UTexture is a UObject and UObjects by default don’t support replication. You shouldn’t think how you make it so, because you don’t need to. The reason is that when you replicate data over the network you should always think of replicating the minimum data possible while still achieving your goal. That’s why you should replicate the state and not the objects themselves. The state in your case is a player that has logined. Think of that as a replicated (RepNotify) boolean variable bHasTraveled. In PostLogin you set it to true, and in that OnRep_HasTraveled() function that fires, you set the texture and other attributes you want. This way you are only replicating a boolean, and you also have your players seeing each other quite right.
I agree with WizardCell, I would say that if you used server travel perhaps both clients may see the replication depending on if your logic is done properly because the replication occurred while they were in level together. If a late joining player comes in, they won’t see replicated variables on other clients because they were replicated prior to the late joining player joining in, and they’ll see only the defaults.
Like mentioned previously an OnRep variable will allow you to create the same function (to an extent) that would replicate when another player joins in and the actor in question is relevant in your network settings.
So for instance if you make your player’s material “green” in game over the network and a late player joins in, you can make a boolean variable such as “IsPlayerGreen” on that player and set it to rep notify. If you are using blueprints you can double click on the variable to create the OnRep function and simply do something like “SetMaterial” on your mesh with the appropriate materials in that function. When the late player joins in, and the actor in question is relevant, the actor with this OnRep function will fire this function for the new player to see the changes whether they are there or not at the time it is originally fired.
Built-in Multiplayer Replicated Texture without external network system ( HTTP, website … )
Texture replication is available for Windows, Android, iOS, Oculus, Linux.
Bandwidth usage is optimized, the texture data sent via network are compressed using external image compression library and then uncompressed when received.
It works on listen and dedicated server.