Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Nelia-Xurina · Feb 03, 2013 at 08:20 PM · networkingmeshlistchunks

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<MP_Chunk> thisChunk = new List<MP_Chunk>();

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<MP_Chunks> Chunks = new List<MP_Chunks>();
     
     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?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nelia-Xurina · Feb 06, 2013 at 02:26 AM 0
Share

Does nobody have a Idea? I tried with

     IEnumerator SendChunk()
     {
         foreach($$anonymous$$P_Chunk tempchunk in thisChunk)
         {
             networkView.RPC("Client_GetChunk", RPC$$anonymous$$ode.Others, networkView.viewID, tempchunk.Serialize());
             yield return null;
         }
     }
     
     [RPC]
     void Client_GetChunk(NetworkViewID view, string data)
     {
         if(view == networkView.viewID)
         {
             $$anonymous$$P_Chunk tempchunk = $$anonymous$$P_Chunk.Deserialize (data);
             thisChunk.Add (tempchunk);
             
             StartCoroutine(FloorkRender ());
         }
     }

But this couses in a Huge lag (That are 65.000 RPC's).

Can't i send a whole list?

avatar image Nelia-Xurina · Feb 06, 2013 at 08:01 AM 0
Share

I realy need some Help. I dont find a solution.

avatar image Nelia-Xurina · Feb 07, 2013 at 07:01 PM 0
Share

$$anonymous$$an...i'm realy the only one who have Problems to send the map over a network?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Feb 06, 2013 at 09:13 AM

Serialize your list of chunks to a byte[] (see this Unity Gems article if you don't know how to do that).

RPC the byte[] produced (RPC supports byte[])

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nelia-Xurina · Feb 06, 2013 at 11:18 PM 0
Share

I tried it already. The Problem is that UnityEngine.Color is not Serizable. So i can't make my List to a byte[].

Any ideas?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Master Server Current Games List 1 Answer

How to Sync List 1 Answer

Network (gameobject)player list JS 0 Answers

Send/Receive a mesh over network 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges