Reputation: 133
I have a Game Manager object marked as Server Only (on the Network Identity), which I want to keep track of neutral game objects in the game.
I need a way to sync a list to all clients when the list changes. So I've been trying to use SyncListString. However, because the Game Manager object doesn't exist on all clients, I'm getting this error "did not find target for SyncList message for x". Fair enough.
So I thought I would us a normal string list in the Game Manager object, with SyncListString on my player object, and update it using Command functions. However, I cannot set the SyncListString to equal the Game Manager list as they are different types.
Am I doing this wrong? is there a better way?
I'm very tempted to just put all of my code in Game Manager into my player script using isServer statements... maybe I should?
thanks for your help!
Upvotes: 0
Views: 541
Reputation: 553
I have tried making the Game manager syncliststring static, however I'm getting an error "Synclist .... cannot be static
You should make your class static not the list itself. If you don't want to do that. just get a reference to Game Manager and use the list from there. (your list has to be public)
Upvotes: 1
Reputation: 553
If I got your question correctly, You should create the Game Manager object on every instance of the game. then update your SyncListString with Command.
you can make your Game Manager static (singleton design pattern).
after that your static SyncListString is accessible from everywhere but updates to it has to be done in a Command function.
Upvotes: 1