PDA

View Full Version : Pathfinding problem



Martti007
February 22nd, 2009, 05:16 PM
I have 100% nicely working pathfinding, where i have moving object (a man) same size as each tile. Now i am facing the problem, where object has become larger than 1 tile (a car) and i need to calculate its path. Is there any good tutorials for such problems or can anyone help me with some advice.

therobot
February 22nd, 2009, 05:56 PM
(Don't take any of this as gospel. I'm really just speculating as I've never tried something like this myself.)

Presumably your tiles have some sort of walkable property for the man. for starters, you may want to make another property 'drivable' or something to that effect. Since your car is bigger than an average tile size, you'll need to include some logic in your pathfinding that accounts for the size of the car.

when you check to see if a particular tile is drivable, you'll want to check to see which neighboring tiles the car would overlap with, and see if those are drivable as well. This process could get really expensive.

If you know the car will only be able to travel on distinct roads, another approach might be to create links to road intersections, and only have the car pathfind among those intersections. I.E. Intersection A connects to Intersection B and C, Intersection B connects to A and D, so and so forth.

I hope this helps. If you come up with a better solution, I'd like to know :)

Blackroot
February 22nd, 2009, 09:32 PM
If this is a 2D plane try pre-calculating the distance between tiles and attaching that data to them, then in the pathfinding algorithim you can check for the verticle gap. Dynamic terrain you'd just have to update the gaps dynamically when you alter there positions.

The actual algorithim would just need to check for nearby gap size while it walks through the pathing.