Hello
I am trying to synchronize a list of game objects across the network. i want each player to have the same copy of the list. once any player adds or removes a game object it should be updated across the network. The initial list should be created by the server and initialized to all connected clients. I know i am supposed to use ClientRPC, but i cant seem to figure out how to use them. i have a bunch of code but its too broken to post here. If someone can point me in the right direction it would be good.
I think SyncList* classes are one way to synchronize the List in unity networking.
For more details https://docs.unity3d.com/ScriptReference/Networking.SyncList_1.html
Same problem , I know that i shoud use synclists. Please can any point me how to use theme beacause i 'm getting errors . here is the code i used :
public SyncList<GameObject> Cards;
public override void OnStartServer(){
NetworkManager netM = NetworkManager.singleton;
cardsList = netM.spawnPrefabs;
foreach (GameObject gO in cardsList) {
Cards.Add (gO);
}
distributeCards ();
}
this code will try to add gameobjects from the registered spawnable prefabs list on the network Manager to synchronized list , but i get this error while runing in the console :
Exception in OnStartServer:Object reference not set to an instance of an object at Player.OnStartServer () [0x00035] in C:\Users\Houcem\Documents\Ballet\Assets\Scripts\Player.cs:32
at UnityEngine.Networking.NetworkIdentity.OnStartServer (Boolean allowNonZeroNetId) [0x00140] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:338
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
Please can one help ?