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

Server side navmesh pathfinding

Discussion in 'Multiplayer' started by snacktime, May 26, 2014.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I have a multiplayer engine that is going to be open source soon, and I'm deciding on what Navigation mesh/Pathfinding solution to make available on the server.

    A few months back I integrated Recast/Detour and used the C# bindings for it to run on the client side. This works great, but it has a couple of drawbacks. One is the C# bindings are not maintained. Second is that if you ever want to customize or extend the pathfinding, you need to fiddle with some fairly complicated C++. Third, and this was really the big one, there was no easy pipeline to create the navmesh. I was exporting the geometry from Unity, which was a pain in itself, and then running that through the minimal C++ gui that Recast has to generate the navmesh.

    So I have pretty much ruled out Recast/Detour.

    The option I'm looking at now is to integrate the A* Pathfinding Project. It looks like it is going to be fairly straight forward to get server authoritative pathfinding working with this project.

    I'm curious if anyone has a better suggestion. My main requirement is that it have a free version of some type that is useful, or be open source.
     
  2. salgado18

    salgado18

    Joined:
    Jul 15, 2010
    Posts:
    84
    I'm working on this right now. The sollution I'll try is to use Unity's NavMesh on the server, then send the path to the clients. I still don't know how to handle obstacles, but since the builtin navmesh is so simple to use and powerfull, that's the first I'll try.

    Are you building the server engine separately from Unity? I found that if you run the "game" passing as argument -batchmode, there is no video or input, so perfect for a server, while still preserving physics, updates and all the UnityEngine functionality.
     
  3. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    I'm working on the same problem. There is a Recast/Detour port to C# that exists for Unity: http://u3d.as/content/cjr-gaming/recast-unity-recast-for-unity/4sG

    I also own A* Pathfinding Project (it was on Madness Sale for $35, I couldn't resist).

    A* Pathfinding Project is actually dependent on the Unity runtime. It is not usable out of the box on the server side. I spoke to the author and he was kind enough to send me an older verison that he had stripped of UnityEngine references in order to run on his server. But I diff'd that code compared to the most recent version and I couldn't make heads or tails of it (very different now). So basically, you would need to rewrite most of it to work on the server side.

    The RecastUnity library comes from this guy who I've been following his series on youtube: https://www.youtube.com/channel/UCUy5QMxQDVlYMSM4Zt483BA

    He says that pretty soon he will be getting to the part where he uses Recast on the server side (right now its just a client side AI demo).

    As for creating the nav mesh, I think there is no easy way around this. But as said above, its possible to do in batch mode on the server automatically.
     
  4. salgado18

    salgado18

    Joined:
    Jul 15, 2010
    Posts:
    84
    Use Unity's builtin navigation mesh system, which creates the mesh automaticaly, and handles obstacles nicely. NavMesh is included in Unity Free, and is as easy to use as "agent.SetDestination(targetPosition);"

    Create the server as a normal game in Unity, and launch it with the command "game.exe -batchmode". This way, there is no video, so it can be the server.

    Unless you are making the server outside Unity, then you need third party libraries, of which I don't know any.
     
  5. palompalom

    palompalom

    Joined:
    Oct 27, 2014
    Posts:
    2
    Hi, I am very new to Unity and I am trying to do a agent based with NavMesh or the A* PathFinding project. It would be very useful if you guy can ad the differences that you found between this two tools.

    For example:
    Which one can simulate more agents without slowing the game?
    best and thanks.