Pathfinding
![]()
I’m rather pleased with myself this morning.
The pathfinding in FS has always been atrocious – experienced players pretty much have to use shift all the time to bypass it. It’s a pain in the ass. Here’s a great example of it going wrong:

The reason pathfinding sucks so much is that my algorithm for it is terrible – it splits the levels up into a grid, each square about the size of a unit. It then checks each square for obstacles. It’s a really innaccurate representation of the level.
This weekend I was reading up on advanced pathfinding stuff, and considering using some kind of Navmesh with movement polygons. Then I was hit by a flash of inspiration – the only thing that matters in FS is corners. If you ever want to make a path in FS, you only ever use the corners to get there – the only points I need in my nav-graph are the corners! Here’s my code for identifying the corners in action:

As you’ll know if you’ve written A* before, the algorithm needs to know how all the navigation nodes are connected. Here’s the same level with that info:

The nav-graph for this level is pretty simple – here’s a more normal one:

Yikes. Lucky computers are fast at this sort of thing! Here’s the same level that the initial algorithm got wrong, but with the new algo I knocked up this morning:

Perfect. You guys can play around with this pathfinding right now – the download is here.
Lots more UI improvements to come.
What's This?
- Visiting the Village is Mode 7's blog.
RSS Feeds
- Everything
- Just Podcasts
- Blog Comments
Mailing List

The Village Twit
Find Out More...
- Find out...
Chat
- Join our IRC channel in your browser
Forums
- Read and post in our forum
Play Determinance
- Download the demo
Search
Useful
Archives
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
Categories
- Competions (2)
- Development updates (8)
- Monday Night Live (10)
- News (824)
- Paul's Re-education (1)
- Podcast (54)
- PR trials and tribulations (12)
- Registered User Bigup! (1)
- The Encounter With Dracula (11)
- The Massive Reading Test (3)
- The Mode 7 Pub Challenge (2)
- Touch and Go (3)
- Uncategorized (278)







2 Responses to “Pathfinding”
§ August 11th, 2010 at 4:31 am
Congratulations on your re-discovery of POV pathfinding! =)
I went through the same steps in my RTS. Squares -> Corners. Of course, my map was grid based at one point.
Still, the thought of ray-casting to each nav-point scares me a little even though I know it works. Just shows you that computers are faster than you imagine.
§ November 2nd, 2010 at 6:41 am
[...] map I have seen so far is made up only of corners. After reading Mode 7′s blog post on path finding I would highly recommend avoiding anything other than corners in your maps because as you can tell [...]