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

Network Movement Server Authority

Discussion in 'Multiplayer' started by hublard, Feb 25, 2019.

  1. hublard

    hublard

    Joined:
    Aug 19, 2015
    Posts:
    79
    Hello there,

    i hope im Right here. I have a Question regarding Multiplayer Game Server/Client.

    Client can Control the Player With W A S D Button. When he press a button Player send Input to Server.

    Server should calculate distance and send back and broadcast to all other Players. Now to my issues.

    1) How should i handle sending Input for example when Player press and hold button down? How do i calculate it Server side.

    2) Other issue, when Server calculate distance and send Position back to Player. then Player walk through Collider because Colliders are still local, how should i do Colliders Serverside?

    3) for example Player can Teleport through a Portal. How should i achieve this?

    i hope someone can help me out for that

    p.S Server is node.js based.
     
  2. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    For example, I implemented everything in FixedUpdate, i.e. My game is ticking a certain number of times in a second, the server is also ticking ... When the object appeared (controller) in FixedUpdate every clock I create a new InputData structure in which all key states (pressed or not) and then call the method in which the controller movement is implemented, then I send these clicks to the server, the server does the same actions and sends the result to the client and the client compares these states, if the states are different, then the client immediately applies the server position ... The most important thing is that the delta for calculations is the same for both the server and the client, otherwise the data between the client and the server will differ