Jump to content
  • Advertisement
Polygon Soup

Tactical Pathfinding - Unity3D

Recommended Posts

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?

Edited by Polygon Soup

Share this post


Link to post
Share on other sites
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. 

Edited by RnzCpp

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!