Path finding

Get help using Construct 2

Post » Tue Mar 26, 2013 3:45 am

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.


This works fine.


This works fine


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 :( nimos1002013-03-26 03:47:34
B
40
S
10
G
2
Posts: 1,147
Reputation: 6,493

Post » Tue Mar 26, 2013 7:59 am

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.vee412013-03-26 08:31:41
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Mar 26, 2013 2:40 pm

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
B
40
S
10
G
2
Posts: 1,147
Reputation: 6,493

Post » Tue Mar 26, 2013 8:00 pm

[QUOTE=nimos100]
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.
[/QUOTE]

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:


Closest cell is outside enclosed area:
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Tue Mar 26, 2013 9:05 pm

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 :)
B
40
S
10
G
2
Posts: 1,147
Reputation: 6,493


Return to How do I....?

Who is online

Users browsing this forum: mercuryus, mystazsea and 16 guests