Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Nav Update

Sign in to follow this  


Tonight I finally got the dynamic navigation updates working. When I started the A* implementation, I wanted to be able to have both a static set of costs as well as a dynamic set of costs associated with each path from node to node.

This way, the static costs would reflect the state of the world in the case when all doors are open, all bridges are working, etc. The dynamic costs would be set above the A* threshold, so that the a* would treat links near an obstacle as impassible.

Anyway, the static A* has been working well for months, but now that we are experimenting with adding player-generated force fields, the A* got confused, and worse, the player could stare through his partly transparent force field and watch the AI suffer...

So, what I do now is to keep a bounding box of the current A* path for each entity. Every time a non-sentient object moves, I subtract its old cost from the dynamic grid, and then move it, and add it's new cost to the grid via a bounding box. I pass this same box to the factory, which iterates through the entities and tests their paths vs the box. If any of their paths touch or cross the box, it conservatively assumes that the new path is impassible, so it ends the current path at the obstacle, where it can create a new plan.

I also had to distinguish between line of sight and line of fire. The force field doesn't prevent the AI from seeing you and coming after you, but they do know they can't shoot through it - currently, anyway. The plan is to have a variety of shields, some can be shot down, others reflect bolts, etc.

Here is a shot of the debug output from a recent test. The red is the static nav cost. The green is the dynamic cost, in this case, of the force field. The white boxes indicate the enemy's start and shooting position. The enemy will actually stop moving to the shooting spot early if he gets a good shot before then. The white line is the current path, which was shortened when I added the force field across it.

Sign in to follow this  


Recommended Comments

There are no comments to display.

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!