Jump to content
  • entries
    4
  • comments
    21
  • views
    12,152

Dynamic AI Paths


Rekindled Phoenix

3,837 views

 Share

I had a challenge last week for this game project. Allow an NPC to come up with a quick way to navigate to a particular place, even if the environment around him is dynamic. Some high-budget games use static node path meshes, which must be a final step in production for each map. I wanted a different approach that didn't require a web of objects hand placed into the world.

 

I decided to create my own rotational node path collection.

 

AI%2BProcess%2B2.jpgAI+Process.jpg

MS Paint FTW!

 

On a pivot, a box would rotate several degrees and create a collection of distances from the target. After the closest one is found, it adds this entity to a PathCollection(), then moves the pivot to this new closer spot.

AI-Tests-05.jpg

An NPC migrating from left to right while avoiding rocks

 

The cycle repeats itself until the radius is close enough to the target.

 

I used a collection of Entities storing a minimum avoidance radius, and calculated terrain slope to manage where NPCs can actually travel. Changing the rotating radius and amount of degrees for each iteration can be used to create a low-density path compared to my example. Such modifications may increase performance in different settings.

 

The best part about this approach is you can store these paths in memory, removing the data as necessary. It also doesn't need to load any additional data with the scene file, it's created on-the-fly.

 Share

9 Comments


Recommended Comments

I've tried doing this in the past but I failed. The problems I encounted is: -

 

1) Performance over a long distance

2) Complicated enviroment with dead ends - you'll search down a dead end and have to come back

3) Complicated enviroments with stairs door etc.

 

You said :-

 

Some high-budget games use static node path meshes, which must be a final step in production for each map. I wanted a different approach that didn't require a web of objects hand placed into the world.

 

Hand placing is an old fashioned approach which no current games do.

 

.... Just trying to save you going down blind alleys.

Link to comment

..i found that Djikstra, i have implemented with some small optimizations, working beautifully fast .. it was easy also to make it tied to game logic in such sense that it can enable/disable search nodes depending on accessibility of specific zones (door open or not, etc) ... I highly recommend..

Link to comment

The most optimum setting would be for a collection hash values (start / end) to be stored for future lookup. Pre-caching the values in a map also works in comparison to my on-the-fly method.

 

An interesting approach .. what sort of speed are you getting for plotting paths over reasonable distances?

Instantaneously for 50 LE Units. I don't need anything past what my camera can see so I haven't tried.

 

I've tried doing this in the past but I failed.

1) Performance over a long distance

2) Complicated enviroment with dead ends - you'll search down a dead end and have to come back

3) Complicated enviroments with stairs door etc.

 

Hand placing is an old fashioned approach which no current games do.

Actually, Fallout 3 and Unreal do. Those aren't necessarily the latest and greatest, but they are still popular in gaming communities.

 

This problem can easily be solved by placing collision data keys on certain objects. If a loop returns a collision key of 'stairs', the algorithm I'm using can be tweaked to adjust height. Changing the radius of the circular checks allows small rooms and narrow passageways to be searched. When an entity exists over a far distance, the radius increases dramatically to save node data.

 

..i found that Djikstra, i have implemented with some small optimizations, working beautifully fast .. it was easy also to make it tied to game logic in such sense that it can enable/disable search nodes depending on accessibility of specific zones (door open or not, etc) ... I highly recommend..

Exactly! This was a similar approach I used to avoid the rocks in the picture. Each avoided model is stored with a minimum node radius in a collection.

Link to comment

I believe a few games use similiar to what you are doing ie character controller points of accessibility/expansion. But they do it offline to build a navmesh from the results.

 

Good example with FO3 and Unreal, however I beleive FO3 was a semi-auto/semi hand drawn navmesh. Unreal/UDK has now abounded waypoint graphs for nav meshes.

 

Check out:-

http://www.ai-blog.net/archives/000152.html

 

 

Hope this helps.

 

Chris

Link to comment

Anything is acceptable if it works for your game but the reasons for using navmesh over anything else seem quite compelling. If I were starting out at the beginning with the hindsight I now have I'd be using a navmesh system from the word go. However, I have implemented an abstraction layer in my AI allowing me to swap fairly painlessly in the future should I need to.

Link to comment

@Rick

I agree with you, NavMesh is a quick way of doing things for all games. If you utilized my method and pre-calculated all of the data, it would be the equivalent of a navmesh without any hand placed nodes. I was just happy to share my solution to the rest of the community.

 

@Pixel

My AI follows a collection of vectors. That way if I ever need to I can swap to another method.

Link to comment

I can confirm that FO3 use navmesh.

 

This apporach can work with NPC that have near and small re-spawn area.

Also it could work with an accurate game design, however i feel this will take more and more work for the designer wich need to avoid maze or complicated area like bridge and river.

 

I did something similar in past, it worked but not as well as i hoped.

 

Anyway happy to see there are other "open" mind wich doesn't have fear to try new way!

 

Good job.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...