Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Mar 11, 2017 at 03:29 AM by blitzcloud for the following reason:

Too subjective and argumentative

avatar image
0
Question by blitzcloud · Mar 07, 2017 at 11:04 PM · networkingserversideauthoritative server

Best practices to synchronize object states

Imagine a reversi game in realtime, without the turn-based structure. Now imagine there's, for example, 500 tiles that can be either white, black or blank (most of the blank on the start).

What's the best way to keep in sync the 500 tile states (example as an enum blank=0,white=1,black=2), to prevent a desync. Should the client look for a mismatch (imagine a case of packet loss)

Imagine all the tiles are on one array, whats the most efficient to contrast them with the client and update them if needed? Apparently one can't send arrays(built-in) over the network, or am I wrong?

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by daggada2 · Mar 12, 2017 at 06:12 PM

If you want to send the entire board state, you might consider converting the array data to a string, sending an RPC with that string as a parameter, and then parsing the string on the other side. Could even use an xml generator to generate the string, could use a simple comma-separated-value, etc. You also can go more fancy with BinaryFormatter. See this link: http://answers.unity3d.com/questions/318593/using-rpc-to-send-a-list.html

If the string gets absurdly long you could look into using compression like: http://stackoverflow.com/questions/7343465/compression-decompression-string-with-c-sharp

If you feel that might not be ideal because the game board is changing several times a second, maybe send the tile changes from the server, and have the client use a request RPC.

So client request change tile x,y. Server receives, updates board, tracks changed tiles for that particular move request, and sends an RPC as above with a string of changed tiles.

i.e. String format could be [tile x],[tile y] ,[color] ;

So the changed RPC string might look like: "1,1,0;1,2,0;1,3,0"

Client parses and sees tile 1,1 & 1,2 & 1,3 have changed to black.

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 blitzcloud · Mar 15, 2017 at 11:27 PM 0
Share

I ended up just not needing what I initially thought I needed. Every tile has a syncVar with an integer for the value, and if they have changed on the server compared to the client it updates it through a command. I'm kind of a networking greenhorn atm.

But your explanation is great and would help in the scenario I pictured so I accepted your answer.

Thanks

Follow this Question

Answers Answers and Comments

86 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Editor Crash !!! 0 Answers

UNet server spawning objects can't be interacted with 1 Answer

UNET moving the players via the server. 1 Answer

Authoritative Server / Player Communication 1 Answer

Turn based game server instances 1 Answer


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