Do we have to instantiate objects on both the client AND server? Or do we just instantiate objects on the server then spawn them?
So far, my code only generates a rectangular map on the host, while the client stays black.
void Awake () {
Debug.Log (isClient);
if (isClient) {
RegisterPrefabs ();
}
}
void Start(){
Debug.Log (isServer);
if (isServer) {
extractMapData ("Assets\\Map Data\\sample_map.txt");
mapTiles = new ArrayList ();
InstantiateMap ();
}
}
void InstantiateMap(){
for (int b = 0; b < y; b++) {
for( int a = 0; a < x; a++){
GameObject toInstantiate = null;
switch(mapData[a, b]){
case 0:
toInstantiate = ocean[Random.Range(0,ocean.Length)];
break;
case 2:
toInstantiate = plain[Random.Range(0,ocean.Length)];
break;
case 3:
toInstantiate = forest[Random.Range(0,ocean.Length)];
break;
case 4:
toInstantiate = hill[Random.Range(0,ocean.Length)];
break;
case 5:
toInstantiate = mountain[Random.Range(0,ocean.Length)];
break;
}
Instantiate(toInstantiate, new Vector3(a, -b, 0), Quaternion.identity);
mapTiles.Add (toInstantiate);
NetworkServer.Spawn(toInstantiate);
}
}
}