0 Favourites

Path finding

  • Hi I made a post regarding a possible bug with path finding, but it got closed due to this:

    Reply:

    "Closing, as this is by design. The Pathfinding behavior will report 'path not found' if you send it in to an enclosed area (as in, an open space surrounded by obstacles). If you tell it to move on top of an obstacle, it will find the nearest open space and move there instead. That's all that is happening here."

    Since i cant response to it. And still dont get why it shouldnt work and as im pretty new to the path finding behaviour my self, maybe someone here can explain why it doesnt work.

    I have added some screenshot further down, that might make it easier to understand what i mean.

    What i dont understand, is what is meant with enclosed area, as it is not send in there? If i place the green box about 20 pixel or so further down or up the screen from the red outline, so it still blocks the opening it works fine, and the path finding will find a path to the side of green square thats pointing away from the enclosed area.

    But if i move it into the red outline it wont, even though the side of the green square pointing away from the enclosed area, is just as available as in the other tests.

    This one doesnt work.

    <img src="http://imageshack.us/a/img268/9292/image1vuye.jpg" border="0" />

    This works fine.

    <img src="http://img829.imageshack.us/img829/6762/image2jzc.jpg" border="0" />

    This works fine

    <img src="http://img401.imageshack.us/img401/3285/image3qi.jpg" border="0" />

    I dont really see what the big difference is between these cases when it comes to finding a path, can anyone explain why placing the green square such a short distance from each other, can make such a big difference?

    It will be a great help as its really screwing up my game :(

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • The little I've used pathfinding, it works by dividing the map in 'squares' (you can define the sizes in settings). The difference in your cases probably is, that in lower test there is 'half blocked' square which the pathfinding object can't use, thus it goes to the square below it.

    EDIT: Manual describes this in more detail.

  • Hi Vee

    I have tried changing the cell size to different sizes, even as low as 4 pixel. But still gets the same results.

    In the manual it says the following:

    "If you ask the pathfinding behavior to pathfind to a destination inside an obstacle, it will simply find the nearest clear cell and pathfind to there instead."

    Which is the case in my test, as the green square is a solid. The red outline is just a sprite with no events or behaviours attached.

    If you look at screenshot 1, there are lots of free cells on both the top and bottom of the green square. Just as there are in the two other screenshots.

    One thing i have been wondering about is the "..find the nearest clear cell.." thing and since the starting position of the blue square in all test are the one shown in screenshot 1, that when it try to find the closest free cell it tries to choose one inside the enclosed area, as they are is closer to the blue square starting position. But then if i compare the placement in screenshot 2, where the green square is actually closer to the blue squares starting position it doesnt really make sense as its actually closer.

    I have added the capx here: Path finding test

  • One thing i have been wondering about is the "..find the nearest clear cell.." thing and since the starting position of the blue square in all test are the one shown in screenshot 1, that when it try to find the closest free cell it tries to choose one inside the enclosed area, as they are is closer to the blue square starting position.

    I think you've got it there but it's not the cell nearest to the player starting postion. It's the cell closest to the target that's not blocked and if that's inside the enclosed area then it can't find a path.

    Closest cell is inside enclosed area:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/pathfindingClosest1.PNG" border="0" />

    Closest cell is outside enclosed area:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/pathfindingClosest2.PNG" border="0" />

  • Yeah i think you are right. Just have to find a way to get around it, i guess.

    It would be a nice update to the path finding, if it marked cells not reachable as blokced, If there were no way to get to them. Or it checked all cells around and object before reaching the conclusion that path is not found.

    But thanks anyway :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Path Movement Behavior
98 52,480
R0J0hound's avatar
R0J0hound
Unread hot topic
55 6,065
Vrav's avatar
Vrav
Unread hot topic
0 Favourites
Found solution for seams
44 6,167
vtrix's avatar
vtrix