Pages

Creatures Community Chat

Friday, January 28, 2011

Pathfinding

My new year has started off pretty good. I've found a new place to move into which is closer to the city and will give me better access to nightlife and work commitments.

Although I haven't produced anything new for 'The Island' in quite a while, I have been doing a good chunk of reading and learning. First off I've ordered myself a copy of Steve Grand's book 'Creation: Life and how to make it' which will hopefully arrive in a week or two. Very much looking forward to getting my nose deep into that one.

On the side I've been reading a book by Richard Dawkins entitled 'The greatest show on earth', which for those of you who don't know is all about the science of evolution. It is predominantly meant to be a book about education as well as reducing creationist claims to rubble, but I'm also finding it quite inspiring in terms of getting back into creating this game. Having a basic understanding of evolution, natural selection and mutations should prove useful somewhere along the line.

As well as getting into some good books I've been trawling the internet to get a better understanding of pathfinding AI, which was where I started to get stuck before the new year. I found an excellent page for gaining an understanding of A* pathfinding which has given me a good grounding.

I've realised that trying to make my own pathfinding system for 'The Island' is going to be beyond my reach (assuming I want to do a decent job) so I've been searching through some of the Unity3D pluggins available and the one I think I'm settling on is simply called 'A* pathfinding' by Aron Granberg. A download, as well as instructions, tutorials etc can be found here:

After some fiddling around I've finally figured out which parts of his code I need to play with to make things move about. Below is a quick video showing the pathfinding in action. You'll have to take my word for it that this is now working with code I wrote myself :P

Basically at my end all that's needed is to tell the code where I want the start and end points to be, set up the ground plane with some obsticles and send the data through to Aron's code. The character (in this case the cylinder) will then move to the set destination, avoiding specified obsticles in it's path.

The next stage will be trying to plug this code into Tiggy and seeing if I can get him to run after a piece of cheese.

Although it all sounds very simple (and with Aron's code laying beneath my own it really is) this is probably one of the most challenging parts of the project. Hopefully with this out of the way I'll be able to get back to creating interactions with the Norns and making a fun game again.

The new year is already looking promissing ;)

EDIT: Wow, just realised how bad the quality of that video. Appologies for that, but hopefully you can still just make out what's going on there.

Haven't really played with arrays until now (couldn't quite wrap my head around coding fast enough at uni to get to them), but at least in theory they're damn powerful.

I'm managed to get the bit of code I was struggling with working and...well, I intend to do an update soon with a good length movie (hopefully better quality) to show you all how it's progressing. Which I have to say is very nicely :D