🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tactical Pathfinding - Unity3D

Started by
6 comments, last by ferrous 6 years, 6 months ago

Hi All,

I am currently trying to create a tactical pathfinding system using Unity's built-in Navigation. The problem is I can't find an elegant enough solution to my problem. This is what I am trying to accomplish:

AI.thumb.png.92997b7fe287251c17dcad816087aa07.png

The Red AI needs to navigate behind those square obstacles in order to tactically navigate to its goal.

This is what I have achieved so far:

 

 

In the above video I have used the NavMeshSurface component. The high-area cost (ie. pink mesh) is generated only if I re-build the NavMesh. I don't want to re-build the NavMesh during runtime, because I have a fairly large level.

My Question:

Is there any way for the Red AI to do tactical pathfinding on top of Unity's Navigation System?

Advertisement

Letting aside all the useful "immediate heuristics" (nearest cover, danger level, etc) that could define behaviour... which might be sufficient/efficient and good enough. I don't know if you're referencing some existing work about this... I'm just assuming that you're (influence maps would suffice). In Unity you can change the A* weights on a zone basis and not by node. So you could make something really rough and not really useful for this. 
If the purpose is to implement a more grained pathfinding, then you should program it. Unity will let you have the pathfinding mesh, that is as far as you can go without implementing stuff. 

One method is propagating information into an influence map and then checking the map underlying individual navmesh polys as you are running the pathfind. In this case, if you register enemy visibility of squares into the map, then you can look up those values and increase the cost of those polys as you run your find. The agent would then avoid those and, in this case, move behind the obstacles instead.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Hi,

Thanks so much for taking the time to reply.

Coincidentally, I have been doing some reading on influence maps. It did inspire me to come up with a theoretical solution (which I have not tested yet):

AI4.thumb.png.2f0fc35bf3a55fd2648479008d3355ce.png

The sky blue background represents Unity's NavMesh and the red squares represents pre-generated tiles with weights. The collision radius of the orange AI (green circle) will determine which tiles provides decent enough weights to traverse through. The weights will be determined by performing Raycasts (~10 raycasts per frame).

I could also optimize further by checking which tiles needs to be tested. If the angle between Orange AI-to-Goal and Orange AI-to-Tile is more than 90 Degrees, then ignore that tile.

Influence maps looks like a good solution. I will continue reading up on it.

Most implementations of tactical pathing use custom A* code and some kind of annotated navmesh. Your approach might technically "work" but it's gonna perform terribly and certainly won't scale to many pathing agents.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

15 hours ago, ApochPiQ said:

Most implementations of tactical pathing use custom A* code and some kind of annotated navmesh. Your approach might technically "work" but it's gonna perform terribly and certainly won't scale to many pathing agents.

Oh no :(. Does this mean I have to use something like Recast? Unity does not allow direct access to the nodes on the NavMesh. I was hoping to implement a simple solution and then perform the actual navigation using Unity's Navigation System.

What about this? Can't I try implementing it on top of Unity's NavMesh?

You might be able to use an asset store pathfinding solution.  I've only used the free version of this: https://arongranberg.com/astar/

In the past, but it seemed to give greater control than Unity's implementation.

This topic is closed to new replies.

Advertisement