-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NavigationServer API proposal #332
Comments
How will agents move between regions? Are the navmeshes aligned automatically or is this the user's job? Afaik, agents won't be able to find paths into another navmesh, if it does not align perfectly to the current navmesh. |
The ideas are:
I'm open to suggestion. |
So when adding a region, its navmesh is used together with the existing regions' navmeshes as geometry input for the Recast process? |
yes |
Does it have anything to do with AStar/AStar2D nodes? |
@hilfazer I think this is only about navmesh-based navigation, not AStar. |
I think we should add some signals to agents as well - similar to the proposed signal of a navmesh's finished generation. For example when an agent stopped moving with information about if it reached its target or if the target became unreachable (e.g. due to new obstacles)? My suggestion would be a signal that gets fired without parameters. Then the user can check the agent's current distance to the desired target point and decide if the agent reached it. Speaking of which, is there a configurable stopping distance? |
This is a nice feedback, I'll add all the possible signals. Regarding the stopping distance; I've set the |
I think that the agent should include anything as configurable parameters, if it is not easily solvable from the outside. I.e. it is hard/impossible to omit the agent radius as a configuration, because the user is not responsible for steering. In contrast to this, stopping distance can be solved by checking the current distance to an agent's target each frame and issuing a stop command if needed. So omitting the stopping distance is good for simplicity. I think that it is crucial to expose all information about the agent's state, i.e. current position, velocity, path, intermediate targets, etc. |
Yes, make sense. I've added the parameter: |
Am writing on this thread rather than the PR, but following on from @starry-abyss suggestion about flying and swimming: With flying and swimming it might also be handy to store the height at each vertex of the navmesh, so you could specify a volume instead of a 2d plane. This also works for allowing e.g. AI characters to jump, without using full physics. On the other hand maybe this is feature creep, because it implies 3d avoidance etc. This is the thing about navmeshes, they are useful for so many things, maybe some concept of customization might be useful. Without customization there is a danger that users would end up having to re-implement their own because some must-have feature is missing (I know I'm expecting to write my own soon for a demo 1st person shooter, but I'd far prefer to reuse something existing, if it offered the flexibility). In the longterm it might be good for users to have some kind of access to the mesh to add their own data, or at least a 1:1 correspondance with their own corresponding navmesh data. So being able to query which mesh, and which triangle ID the agent was on and the barycentric coordinates would be useful. I don't know whether recast / detour rejigs the original geometry you give it, which might make this harder. Certainly it must do in terms of carving. You could alternatively have the navmesh allow extra custom data internally, such as adding height to each vertex, and have it interpolate for you, and deal with carving. The other thing which is tremendously useful is being able to do low level movement yourself using the navmesh as physics, rather than relying on it for pathfinding. Cheap queries like line of sight tests between A and B without any pathfinding that might be called many times per agent per tick. I don't know if this is possible already I haven't tried the existing system. Also things like 'find me the nearest BLAH' for AI, or choose me the route with the best cover etc. |
3D avoidance sounds nice, but I was thinking about a simpler feature.
|
There is a least one concern about W3's grid approach. If there is a bridge over a canyon, no agent can pass under the bridge (only if it's a broken bridge). So it's either everyone can cross the bridge, or everyone can pass under it, not both. |
Integrating "official" Detour (from github.com/recastnavigation/recastnavigation) would ease multiplayer engines where the Godot game would only be a "client" of the world state. The navmesh could be only built once, and shared between the player (launching a Godot game instance) and the world server (on a remote server, in another language). The navmesh could even be streamed from the server to the client after client authentication. This would ensure that both the server and the client have the same "view" of the walkable area. Thus, the client could not move to an area unwalkable by the "agents/IA" controlled by the server. dtNavMeshQuery::moveAlongSurface() is not a joke. Re-implementing an imperfect equivalency would not be a small task. Lots of engines already use recastnavigation.
Some people uses "official" recastnavigation in web games :
Coding and Using an only-Godot implementation of a navigation system, seems to me maybee a little short-sighted. It should work, it would work, but it would maybe not be compatible with anything already existing :
Please consider not reiventing a wheel that works, and using "official" recastnavigation (as per this proposal and as per godotengine/godot#34776 ) |
@folays I think that with godotengine/godot#34776 is already possible achieve that. Could you explain your concerns? However, the reason I didn't use the detour library directly (even if I'm still using recast) was because of leaking control over the core code (from the outside of the library). Integrate the Region Merging Mechanism would have been much more complicated and less polished.
This function seems a specific version of the |
Recast is for building the navmesh, Detour for using it, I think I got it right. I think I got wrong your godotengine/godot#34776 which I admit I did not read, I naively thought that it was an implementation of the first URL of this proposal ( https://docs.google.com/document/d/1LyXMunKJz1LDSfl6IJHK00SVKeG60p4bPyxZcdM7YqE/edit# ) which suggested :
But it seems that your are only using from recastnavigation the "Recast" part to build the navmesh. I do not really have a concern about the "Recast" part. The navmesh should be built only once, and shared between the godot-game-client and the server. (or done multiples times, if we are sure that the client and server generate the same navmesh everytime) My concern was more on having the same code (both on a Godot game client, and a server) using the navmesh, to ensure that the player (using Detour inside godot) has the same walking capabilities and areas that the agents (using Detour on the server). For me, the only really needed "Detour" part of recast navigation in Godot would be : moveAlongSurface. This is indeed very similar to move_and_slide :
But move_and_slide is very buggy, and hard to get right. To make move_and_slide works with stairs, some people uses a RayShape to make them "naturally" cilm-able. Making the player only able to walk on the navmesh, by feeding human input to moveAlongSurface immediately resolve all problems. Stairs are naturally "transformed" into a slope by Recast. moveAlongSurface ensure that the player will always be on the navmesh, and such reachable by the agent driven by the server.
Aren't you talking about the "tiled mesh" ability of recastnavigation (Detour) where you are able to "stream" navmeshes, i.e., at runtime, "add or remove" navmesh from the global world? (needed in very big open worlds) ? And for the disclaimer, I never released a game in my life, although I tried multiple client engines (Unity / Three.JS / BabylonJS / Godot) with always a Go server (+ arl/go-detour or CGO+Swig+official-recastnavigaiton)
|
I think that you are over concerning, and some requests are not related to the Detour or not, the same code runs on clients and server for both mesh generation and path finding. Regarding But let's suppose that you need a function that doesn't care about collisions, so something that allows the character to slide along the navigation mesh (as seems to do the |
Regarding Navigation only, assuming that the generated navmesh is the same on the server and on the client : moveAlongSurface does not seems to be trivial to integrate, as per http://digestingduck.blogspot.com/2010/08/detour-agent-movement-progress.html Going from current_location to next_location is not the hard part. Figuring out what next_location is, is the hard part (http://digestingduck.blogspot.com/2010/07/constrained-movement-along-navmesh-pt-3.html) Agents may generally do not need to figure out next_location, their next_location would be aiming to be the player_location if they want to attack it, and the navmesh would give all intermediate positions the agents would need to go to get to the player, and you would only have to go though them, and interpolate them as needed. But players needs to figure out next_location after an human input, based on player_location + human input (go "forward" or "strafe left" etc...) Currently in 3.2 the only player-controlled navigation solution is to use geometry-constrained navigation. get_closest_point() and family does only help a little for player-controlled navigation. Example (using navmesh API present in 3.2) :
You could of course use get_simple_path() which results should made you infer that there were an obstacle somewhere. It won't help you slide along the wall. And as I said previously, the 3.2 geometry-constrained navigation does not work out of the box (no stairs, or stairs with RayShape but then you can climb really high slopes... and snapping does not work anymore...) I am concerned because I previously tried to use some ThreeJS plugins with custom navigation code, which the author overlooked, helping only the agent to navigate. Inherently the geometry-constrained and the navmesh-constrained navigation do not have the same "view" of walkable area, even with a given "climb height" (due to the voxelization of the geometry during the Recast part). Did you merge proposal only helps agent to navigate, or your custom navigation code also helps human-controller player to navigate? Don't you think there should be a way for a human-controlled player to have movement constrained by the navmesh, and that this possibility would fill many needs, that it should be considered "generic" and not specific, and thus worthy of provided by the Godot engine ? I would like to repeat myself one more time:
The only downside that I see to moveAlongSurface() (and thus Detour) is that it constrains to a navmesh, so there is not support for a player which would like "to jump". In any case please consider that in my eyes your merge proposal is an improvement to the actual situation, I'm only arguing about human-controlled player navigation on a navmesh, which few consider. |
You have prejudices on the new I know that detour is awesome and works great, but you are not understanding what I'm saying due to lack of knowledge of some new keywords that I used (like In the above comment there are several inaccuracy that don't apply to the new navigation. What I would advice is - give it a check, out of prejudices, then come here and open an issue for anything you think we can improve. I'll be really glad and happy to discuss and if possible implement what's missing. 😊 |
Fixed by #34776. |
Link: godotengine/godot#34776 |
Navigation Server API proposal
This is a
NavigationServer
's API proposal for which is created taking in account this feature proposal: https://docs.google.com/document/d/1LyXMunKJz1LDSfl6IJHK00SVKeG60p4bPyxZcdM7YqE/editPreface
The
NavigationServer
's main features are the navigation mesh generation, path finding and collision avoidance.Navigation mesh
The navigation mesh generation is done using the
Recast
software. It's possible to pre-bake the mesh or generates a new one at runtime. The server has the concept ofMap
where it's possible to load and unload part of this map at runtime (feature especially useful for open worlds games).Path finding
Using Godot pathfinding
Collision Avoidance
Collision Avoidance is done using using two different technologies, so to give all the necessary tools to the developer that only one solution can't provide:
The Dynamic recast is used to regenerate part of the map that is occluded by a dynamically moved object (this operation is known as carving). This operation is heavy to compute, especially if you have many moving objects in the scene, and for this reason it's really nice use it for non moving objects not each frame.
The other collision avoidance method is integrated using RVO, which is computationally cheapper and easily parallelizable, allow to steer the character and avoid collision between dynamically moved objects and other characters.
Detour and RVO will work together in this way:
Character
ask the agent node for the next position to reach.Character
computes the velocity toward that point.Character
send this velocity back to the agent that can correct the velocity using RVO.Note 1: By
Character
I mean something created by the user.Note 2: On the point 1, the agent can automatically decide to perform detour, if not path is yet generated, or if the actual character location is too faraway from the idea path (due to some dynamic obstacles).
NavigationServer API
NavigationMeshGenerator
bake(NavigationMesh res, Node root_node)
clear(NavigationMesh res)
2D / 3D
This server accept 3D type objects, but will be used by both 3D and 2D nodes.
Nodes
The
PhysicsBody
andPhysicsBody2D
will have a new checkbox,collision_avoidance_obstacle
. When the body is a dynamic body, and CAObstacle parameter is set to true, an obstacle agent for that body is created; the sphere radius is automatically computed so to enclose all the Body shapes.These nodes are added:
The nodes Navigation and NavigationMesh will remain the same from the user prospective. Under the hood when a navigation node is instantiated a new
Map
is created, while aNavigationMeshInstance
will instantiate a newRegion
.The
NavigationMeshInstance
will have some more methods and events that are used to regenerate theNavMesh
. A signal is emitted once this process if finished. (During this period the game is not blocked and the NavMesh is replaced only once the new one is available).Multithread
To make this server multi thread safe, the mutable commands will be stored in a Mutex array that will be flushed during the sync phase. All other queries, (like:
map_get_path
, etc...) that are immutable can be called at any time by any thread (except during the sync phase, where any call to these functions is blocked by aMutex
).The text was updated successfully, but these errors were encountered: