Tugcga / PyRecastDetour

Python navigation mesh library for Windows, based on recastnavigation. Can be used for generating navmesh and finding shortest path between points
11 stars 3 forks source link

How can I use it in Game Server #9

Open WenzhiShao opened 1 year ago

WenzhiShao commented 1 year ago

Hello, Could I ask a question? I need do path_find in server. What the server gets is Unreal Local position from client, and server has the *.bin file which is export from unreal level, or navmesh generated by your utils (Load level and then export navmesh) My question is: Do I need to convet unreal local position into Recast postion? If :Yes, How can I do it?

Tugcga commented 1 year ago
  1. If you bake the navigation mesh in Unreal and then save the result as *.bin file, then this file may be not compatible with the module. Because the Unreal can modify format, extend it or create their own format to store navigation mesh data. So, before using navmesh, generated in other application, you should test it.
  2. To find the path between two points you should simply call the method navmesh.pathfind_straight with two arguments: the first argument is a tuple (x1, y1, z1) of the start point, the second argument is a tuple (x2, y2, z2) of the second point.
WenzhiShao commented 1 year ago

Thanks, a lot. I've found a solution. Maybe It will help other users. The UE has a custom Recast&Detour solution, especially the Coordinate System is different: like the location yuo got a in UE which is (-970, -230, 180) , but the counterpart in reactdemo(using the navmesh generated from obj file exported from UE) is like (-1.X, -0.X, 0.X). So If anyone wants to get same nav result in server, you should pack the custom Recast&Detour c++ code into python lib. This rep [https://github.com/hxhb/ue4-export-nav-data ]provides a plugin to export your UE navmesh. And the author extracts UE recast&detour code in rep [https://github.com/hxhb/ue4-recast-detour].