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

Question How do you make responsive server-authoritative player movement?

Discussion in 'Netcode for GameObjects' started by Prog_Meisters, Feb 6, 2023.

  1. Prog_Meisters

    Prog_Meisters

    Joined:
    Mar 25, 2013
    Posts:
    8
    I'm working on a simple multiplayer 2D topdown tank game using NGO. The base of the tank handles movement and is controlled directly by the player, while the turret can rotates slowly towards the aiming reticle.

    First pass I tried making it all server authoritative at first, where the player only enters the inputs, but the result, even with a microsecond of lag running on the same machine, felt horrible. Basically I want the player to feel responsive to inputs and needs to respond instantaneously, or at least appear to.

    Second pass I simply made the tanks into Client Transforms so the client could control them. Feels great, but not server authoritative. I made the turret rotation into a NetworkVariable. The client tells the server where it would like to aim, the NetworkVariable updates and the client tries to match that rotates. Looked good until I introduced some artificial lag and it was very stuttery. It also made aiming bullet impossible and makes them spawn out of sync with where the turret is.

    Bullets work great. I followed Tarodev's video on NGO. So when I shoot on the Client, it spawns a dummy bullet, then ServerRpc the spawnpoint and direction to the server which spawns the real bullet and ClientRpcs more dummy bullets to the clients. It looks and feels good and is close enough to be viable.

    Now how I can I do that with things like movement and rotation? Is it all setting up dummy client visuals that only exist kind of where the server thinks they exist?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,511
    You are asking for the holy grail. :D
    The terms you want to research are (client-side) prediction and reconciliation.
    If you don‘t want to bother with this and aren‘t too far into making your game I would recommend Fish-Net which has these and a number of other features NGO doesn’t (yet) support already built-in.
     
  3. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    @Prog_Meisters unfortunately NGO doesn't have built-in client-side prediction and reconciliation . You can still implement this yourself.
    This video and this blog post will give you an idea of what you have to do