Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Client Server Architecture

Discussion in 'Multiplayer' started by LayZ1307, Oct 6, 2021.

  1. LayZ1307

    LayZ1307

    Joined:
    Aug 14, 2021
    Posts:
    16
    I'm trying to wrap my mind around some concepts and im trying to find out how I need to think of client server coding... Something like a simplified overview.

    I am going to have to code server side logic inside of the client (unity) and it is going to run from an uploaded headless version of unity(server version of the game)?

    And how am I sure of which code is ran on the server side/headless? I know I'm to mark parts of the code as commands and rpc calls, which I have to look more into however this appears to be the only notifies of being code ran server side or inside of the headless version separate from our client while we are connected to that server.

    Or if I were to write code and say these scripts are to be executed from the server how am I sure that calling those methods in those scripts are going to be ran from the server? It seems a little ambiguous as if I were to just code server code and call those methods it somehow needs to know its server code and where to be ran from.

    I've been kind of putting off learning sockets until the game is more finished to then make it multiplayer, however the listening/server socket may deal with running the server logic from the server...

    And when we do the sockets for tcp or udp are we establishing that socket connection passing a small amount of data and closing that connection or are we staying connected the full duration of the game passing data back and fourth to the server?
     
  2. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    And what is there to think!?
    If you have a game with fast gameplay, then priority should be done on the UDP protocol, if a step-by-step game is suitable for TCP, but it is advisable to do everything on UDP because it is faster

    All the logic of the game needs to be done on the server, clients are just observers of the game (with the ability to control someone or something if the server allows it) receiving data from the server and sending input (if someone or something is being controlled), the server receiving input from clients applies them to objects and then sending the result of this input.

    It's very simple, the main thing is to figure it out... And besides, nowadays there are a lot of network solutions in the public domain.

    I recommend looking at the description of client-server interaction from Valve and tutorials from Glenn Fiedler.
     
  3. qbvbsite

    qbvbsite

    Joined:
    Feb 19, 2013
    Posts:
    83