Hex World AI – Starting Out

Hex World needed AI and after working for a while on utilities and small features for Hex World I had been itching to take on something bigger for the game.

The first thing I tried to do was use Unity NavMeshs for the AI pathfinding, but because Hex World is made up of GameObjects stacked against each other, the NavMesh would not generate correctly. Differing heights would either be ignored or the mesh would overcompensate, chunk boundaries block mesh generation completely and the generated NavMeshs wouldn’t have helped the AI path in a straight line.

So I worked on my own pathfinding system, I decided that Hex World would lend itself well to the A* algorithm and immediately started building a system based on that algorithm. The algorithm however would mean that AI would be very obviously moving in a grid from one node to the next so I decided early on that the algorithm would provide a path to an agent that would walk the path while dragging the actual character along as though it is on a leash. The result would allow the character to loosely follow the path in order to appear a little more natural.

So here is the earliest implementation of the A* AI in Hex World:

And here’s a larger test of the implementation:

Advertisements

Author: mfhartydev

I'm a programmer who loves games and has always dreamed of making them.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s