godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Improve Navigation with multiple agents #1966

Closed nathanfranke closed 1 year ago

nathanfranke commented 3 years ago

Describe the project you are working on

Prototyping an RTS game in Godot 4.0

Describe the problem or limitation you are having in your project

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Stay on mesh flag: image image

If this enhancement will not be used often, can it be worked around with a few lines of script?

Most of these issues cannot be worked around easily. The only alternative would be to make a new pathfinding system from scratch, or use a custom module.

Is there a reason why this should be core and not an add-on in the asset library?

NavigationServer is already part of core.

barbaros83 commented 3 years ago

yes this is something im struggling with because the astar and navigation node in 3.2 doesnt provide support for calculating multiple paths at once. and i played around with the navigation agent in 4.0 and that also doesnt seem to work with multiple units, maybe its possible to code around that limitation but it would be very nice to have support build in for an rts like scenario where you need to move lots of units around at the same time.

Killfrra commented 2 years ago

The problem is that the avoidance library doesn't know what's going on with the navigation mesh, it works separately from building the path in its own little world. But while browsing the net, I came across this demo (turn on the obstacle checkbox). That is, it is theoretically possible to inform lib about the boundaries of the NavMesh, saying that these are obstacles and yes it will probably affect performance.

It turns out that others do this:

If you are using a navmesh based graph, it is very likely that you want your agents to not go outside, and perhaps even avoid the border of the graph. Fortunately for you, there is a simple script written just to do just that. It is called RVONavmesh and can be found at Components -> Local Avoidance -> RVO Navmesh. Add that to any GameObject in your scene and it will, when a graph is scanned or loaded add it's border as an RVO obstacle. Source: A* Pathfinding Project -> Local Avoidance

And as for multiple paths... I don’t know (yet)