Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Rookie Advice Sought

Discussion in 'Multiplayer' started by moproductions, Feb 24, 2024.

  1. moproductions

    moproductions

    Joined:
    Sep 28, 2010
    Posts:
    88
    I'm working on my first multiplayer game, which is a board game called Shobu where players take turns moving pieces on the board like Checkers or Chess. With enough tinkering I was able to get basic stuff like the pieces moving on both client and server but what I can't do at the moment is synch up the main class (Shobu.cs) which stores all of the game state stuff, etc, so when the server player is done the client player can now move. I'm not sure of the best way to do this. Should it be RPC calls, NetworkVariables, etc? Any advice would be great but once I have that down I should be on my way.
    Thanks!
    -Mike
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    The amount of state for a chess-like game is trivial, even a byte[] would suffice to record which type of unit is on what grid field.

    RPC are good for sending changes to state. Since state changes only on user action, a turn based game would work well with RPCs.

    NetworkVariable (especially collections) let you sync the entire state at once, but it will sync the entire state for every change unless Netcode has internal optimizations. In this case it would be an easier way to sync the byte[] for every change since any bandwidth inefficiencies are negligible (8x8 grid = 64 bytes plus overhead to sync up).
     
  3. moproductions

    moproductions

    Joined:
    Sep 28, 2010
    Posts:
    88
    Ok thank you, I was actually leaning towards RPC's since this doesn't happen very often. I'll look into using NetworkVariables for something else to show off heh.
    Thanks!
    -Mike