I’m making a project loosely based on the Blueprint Multiplayer project on youtube (except it’s a PhysicsBall project with some edits). I’m trying to do something the series doesn’t do: Replicating properties of the Pawn (PhysicsBall) in a multiplayer game. (The series uses entirely different classes of character for character select so I can’t reuse that code).
(I’ve since found out some things, like that GameMode is server-only and PlayerControllers only exist for their respective players and the server, which the tutorial didn’t mention.)
What I want to do is have players select a color and material in their own options menu, then send that information to the server and replicate it. I’m currently using the tutorial’s PlayerInfo struct for this, stored as a member of the LobbyController class (PlayerController subclass).
After players connect to a lobby, the LobbyGameMode adds them to the list of PlayerControllers, spawns them in, then updates everyone with the new player list: http://i.imgur.com/xawMfZV.png
The respawn event: http://i.imgur.com/2gF8fiv.png
The event that updates everyone with the player list: http://i.imgur.com/QjnIcBT.png I have arrays of PlayerControllers, Pawns and PlayerInfo structs. This event clears/reconstructs the Pawns and Playerinfos arrays, then sends all three out to each PlayerController (yes, I know not all the PlayerControllers will be there on clients. I mostly don’t use them.) The PlayerInfos are definitely all valid and correct, since the menu gets the names from them.
This event in the LobbyController class updates the list of players in the LobbyMenu, then sets players’ materials and names: http://i.imgur.com/sSUYNJB.png (Nothing I’m doing here needs the PlayerController array so that’s not the issue- I only use it in the menu to see which player in the list is the owning player.) There’s a cast from Pawn to PhysicsBallBP here which should always succeed (since the PhysicsBalls are spawned and possessed before the GameMode syncs all the info). It doesn’t always succeed, but this isn’t the entire problem.
These events in PhysicsBallBP actually set the names and materials/colors from the given PlayerInfo: http://i.imgur.com/idhM1K0.png It runs on the owning client, since everyone is doing this separately from their PlayerController. This is where it gets weird:
Clients can only see their own names until someone else connects after them - then they can see everyone’s name except the one who just joined.
Clients can’t see anyone’s material except the server’s, and then, only when someone joins after them.
The server can’t see anyone’s info except their own - all names and materials are the BP default no matter how many people have joined.
In the LobbyController event, a lot of PhysicsBallBPs are null - the newest spawned one is null for everyone else, and everyone else’s are null for the newest spawned one.
I think this is two separate problems: First, maybe the balls aren’t replicated so soon after they’ve been spawned? If so, how should I be updating everyone’s data?
Secondly, even when the PhysicsBall is valid, no one’s material except the server’s gets changed anywhere. I have no idea about this since names are being sent out fine, and the material is just another field in PlayerInfo. All the actual editing of the BP, both names and materials, happens on the client for every client. Any help would be appreciated.