Sync dynamic properties to clients
In my game i store player properties as a dictionary since i have a lot of them:
public class Resources : NetworkBehaviour {
public enum Property {health, energy, radiation, speed, etc.}
private Dictionary<Property, float> properties = new Dictionary<Property, float>();
public void ChangeProperty(Property prop, float value){
properties[prop] = value;
}
}
I can easily introduce new properties that way and also prevent duplicate entries. The properties can only be changed on the server. But how do I sync them to all clients? Every client should know about all the properties of all other clients (for UI reasons).
I startet with an RPC call but that doesn't work because the other players don't have localPlayerAuthority. That would only change the properties for the localPlayer.
How would someone achieve this?
I guess one possible solution would be a properties GameObject with serverAuthority which is referenced by the player objects. The dictionaries could be changed to list of structs and synced over SyncListStruct
Is there a simpler or more efficient way?
Your answer
Follow this Question
Related Questions
syncvar not changing after command 0 Answers
Sync complex variables and components over network 1 Answer
uNet rotation syncing problem 0 Answers
I need help with SyncVar. 0 Answers