Jump to content
  • Advertisement
Sign in to follow this  
BUnzaga

Creating Pathfinding Tables... how?

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having a hard time visualising how pathfinding works. I have read several tutorials on the subject over and over, and although I understand the concept behind pathfinding, I am having a hard time putting it into something workable. Let's take a simple 2d screen size, of 800x600. Lets say I want to divide the screen into blocks of 10x10. So that would be a grid of 80x60. I know each block would have to somhow contain the weight it is to go from itself to the other 8 blocks that surrond it, and infinity for blocks that aren't passable. So the question is, how do I track all this? Do I manually write out 4,800 arrays, or tables, or what is the best way to create the tables. Lets say I get into adding walls and stuff, obviously I will set the tiles weight to infinity, but then how does the pathfinding system know that this tile is no longer the origonal weight, but the new weight? I won't even get into a 3d environment, where you can go from upstairs, inside and out of building, etc. Please help me understand. BUnzaga

Share this post


Link to post
Share on other sites
Advertisement
If you have the cost to move into a given block, then you only have 4800 values to store. Then, read about A* to find the optimal path from one point to another. Google A STAR to find lots of info, or search this forum, where there are gobs of links and information.

Share this post


Link to post
Share on other sites
Your screen has 800x600 = 480,000 pixels on it! Do you write out the color for every pixel? These pathfinding values are no different.

Share this post


Link to post
Share on other sites
- "So the question is, how do I track all this? Do I manually write out 4,800 arrays, or tables, or what is the best way to create the tables."

Usually the cost of entering a square is the same regardless of which side you come from, so you only need 4800 values, not 4800x8 values.

- "Lets say I get into adding walls and stuff, obviously I will set the tiles weight to infinity, but then how does the pathfinding system know that this tile is no longer the origonal weight, but the new weight?"

A wall is something you add once. So you set the weight of that square to the appropriate value (infinity or whatever). It's just a value, no magic there, no need to remember old or new values.

- "I won't even get into a 3d environment, where you can go from upstairs, inside and out of building, etc."

It's no different in principle, just more adjacent squares for each one.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!