Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!






Pathfinding

Posted by r1ckparker, 30 May 2011 · 445 views

I've been on holiday this week, so not got much done. Last time I got monsters in and randomly walking around, but when they see the player they should walk towards him and this calls for pathfinding.

There's a fantastic page here which explains how it works.

http://www.policyalmanac.org/games/aStarTutorial.htm

I could have downloaded a library but I thought it would be better to do it myself. Also I couldn't drop it straight into the game, because it would be a nightmare to debug in first person! I therefore programmed it as a separate function and I can just drop it in now. It's my own version of the algorithm called 'A+' because you can't travel in diagonals, just on the x and y axis. This is because the game is grid based (like Dungeon Master or Eye of the Beholder for example).

Here is a demo video, the starting point is the green square and the finishing point is the red square. Purple squares are checked (on the open list) and the blue line is the final path.



So all I need to do is replace the green square with the monsters x,y and the red square with the players x,y and it should work...




May 2015 »

S M T W T F S
     12
3456789
10111213141516
171819202122 23
24252627282930
31      

Recent Entries

Recent Comments

PARTNERS