Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Multiplayer NavMesh Build

Discussion in 'Navigation' started by jpeg_, Nov 26, 2018.

  1. jpeg_

    jpeg_

    Joined:
    Sep 5, 2017
    Posts:
    2
    I'm building a online game, and the players need to build the navmesh at runtime. I wanted to know if I can guarantee that the navmesh builded is the same for every player.
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    433
    I wouldn't count on that, Unity has had a history of not providing the exact same results on different platforms and cores.
    Besides that, you're basically introducing client authority in your multiplayer game, something that you generally want to avoid and instead have your server be authorative.
    May I ask why you want to take this approach?
     
    jpeg_ likes this.
  3. jpeg_

    jpeg_

    Joined:
    Sep 5, 2017
    Posts:
    2
    Thanks man, I want this approach because otherwise I would have to share constantly the position of the walking game objects over the scene.
    How do you recommend to share navmesh data in a multiplayer game runtime ?
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    433
    Well if the game is multiplayer you will have to share and synchronize the positions regardless, else you won't see the other players moving.
    It'd be much safer to have your server have the NavMesh, have the players send in the destination they want to go (like by clicking on the floor), then have the server calculate the path and handle the movement after which the results get sent back to all the users.
    That's an example of server authority: the clients only process the player inputs while the server handles the game logic, then sends the results back to the clients. This will generally ensure all players stay in sync, as well as reduce cheating options.
     
    TheAngryCoder and jpeg_ like this.
  5. TheAngryCoder

    TheAngryCoder

    Joined:
    May 24, 2020
    Posts:
    3
    Hi. How would the server have a navmesh?? Can't I just tell the server the localplayers current position for it to then send this to the other players? I'm not very concerned about cheating to be honest, its not a shooter game, its point and click.
     
  6. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    433
    You can definitely just share positions among players without server authority, if I'm not mistaken that is what the Network Transform component does.
    As for how the server has a Navmesh, normally speaking every build of your game will have a Navmesh since you bake those in the editor, then make your game build. Your server is basically running the same executable with different permissions.
     
unityunity