Quantcast
Viewing all articles
Browse latest Browse all 165

Sending Level Data over Network

Hello. I'm trying to send Chunkdata from a Level over the Network. There are 256 Chunks where each is 16*16. Every cube (1*1*1) is saved in a List. public List thisChunk = new List(); The MP_Chunk class save the x, y and z Position as int, 2 bool variables and 6 Color Variables (For each side of every Cube). public class MP_Chunk { public int x; public int y; public int z; public bool isFloor; public bool canDelete; public Color Color_Top; public Color Color_Bottom; public Color Color_Left; public Color Color_Right; public Color Color_Front; public Color Color_Back; } How can i send the Chunk Data for each Chunk? The Chunks are saved in a List too. public class World_ChunkLoader : MonoBehaviour { public static World_ChunkLoader instance; public Transform ChunkObject; public int chunk_X_Width = 16; public int chunk_Z_Width = 16; public List Chunks = new List(); IEnumerator Start() { instance = this; for (int x = 0; x < chunk_X_Width; x++) { for (int z = 0; z < chunk_Z_Width; z++) { MP_Chunks tempchunk = new MP_Chunks(); tempchunk.x = x; tempchunk.z = z; tempchunk.isLoaded = false; Chunks.Add(tempchunk); } } yield return StartCoroutine (World_LoadFirstChunks()); } void FixedUpdate() { instance = this; } IEnumerator World_LoadFirstChunks() { foreach(MP_Chunks Chunk in Chunks) { Transform tempFloor = Network.Instantiate(ChunkObject, new Vector3(Chunk.x * chunk_X_Width, 1, Chunk.z * chunk_Z_Width), Quaternion.identity, 0) as Transform; tempFloor.name = "Chunk (" + Chunk.x.ToString () + "-" + Chunk.z.ToString () + ")"; tempFloor.parent = transform; Chunk.isLoaded = true; yield return true; } } } public class MP_Chunks { public int x; public int z; public bool isLoaded; public Transform ChunkObj; } So how can i send this Data over the Network? Without a huge lag? Any Ideas? I tried it over Network.Instantiate, but then the meshdata for the Chunk are not loaded. I hope u understand my question. How to send a List of information over the Network. My Idea is, that only the Host (Server) has the level data. And on Connect or on Update it sends the Data to each Player. But i think this is to much Infromation, or?

Viewing all articles
Browse latest Browse all 165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>