Search Unity

NetCode UI game

Discussion in 'Multiplayer' started by reiconrooc, May 9, 2023.

  1. reiconrooc

    reiconrooc

    Joined:
    Aug 11, 2018
    Posts:
    16
    I am working for a NetCode (client/server) game based on the UI. For example a simple button trigger an action that is sent to the server, processed, and the client obtain the result.

    I am looking for the correct way to manage networkObjects and messages.
    Every player should only see his interface and not other players UI, so i think using a player prefab is not the correct way. What I am thinking is to have an object/script in the server side and the same object/script in the client side. The client send by an RPC the action providing its identifier and another ID to identify the match.
    The server side, that receive request from all players and all matches, send a reply to the sender.

    Is this the correct way to approach an UI game?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    Well, whatever the implementation make sure you do not network the UI itself. The UI is just a detail, the only thing that matters is transferring the game‘s state across the network. Ideally your UI communicates with your model classes only, who then send and receive network messages as needed. On the other end the model receives events and updates the local UI accordingly.
     
  3. reiconrooc

    reiconrooc

    Joined:
    Aug 11, 2018
    Posts:
    16
    So to let know the UI when the client side receive an update from the server, need I the clientRPC set a variable and the UI should manage the variable change with a listener?