Archive for December, 2009

It’s time to break out…

Tuesday, December 8th, 2009

…the pathfinding algorithms.

Working on A* to navigate the waypoints.

Then on summarizing it here.

Finding your way about

Thursday, December 3rd, 2009

I’ve rehauled the entire waypoint system to allow more intellegent navigation of an indoor environment.

The waypoint system I had before simply said ‘if you can’t find the player, just loop around these waypoints until you do”. That’s alright when the AI has a large field of vision, or is near the player, but in an indoor environment with multiple paths and many barriers, that just doesn’t cut it.

Here’s a shot of the current system. It’s probably about 80% done:

What you see here is a small section of the level I’m using to test navigation. The textures are slightly random and all very free. Hence the goofy fluorescence. Scattered throughout the level are waypoints. They show up in the editor as cubes of various colors, but they are invisible in the actual game. Waypoints are grouped into ‘paths,’ marked by color. Each waypoint stores information about itself, such as what path it is in, its position in that path, and what paths are connected to that waypoint.

Waypoints are split into paths for several reasons. The prime reason is that it allows the AI to reach a specific destination much more quickly. If the AI is alerted to the player’s presence by an alarm (something which, in this system, would be extremely easy to implement), the AI can figure out how to get to the player from even a great distance away. It simply checks what path the player is on, then, if the AI is not on that path, can check the nearest connected path, until it figures out a route and begins traveling it.

It’s not quite working yet. I’m having some problems keeping the AI from getting confused if it sees the player, chases him, and then loses sight. It should just grab the nearest waypoint that leads to where it lost sight of the player, and travel along that path, but oftentimes it grabs an impractical waypoint as its target (at one point I was crashing the game with a possibly infinite loop. Oops).

Other minor tweaks abound, too, including tighter movement for the enemy more suited to indoor environments.