Pathfinder Long Loading

Discussion and feedback on Construct 2

Post » Thu Jan 31, 2013 12:37 pm

Messing with the new awesome pathfinder plugin and applied it to quite a large layout, the layout now takes quite a while to load, close to 30 seconds.

Is this normal? The layout size is 13000, 6000
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Thu Jan 31, 2013 1:32 pm

The pathfinder behaviour uses a simple grid-based A* search algorithm in order to determine routes between cells. Assuming you're using the default cell-size of 20, then your algorithm is generating and searching through 13000/20 * 6000/20 = 195000 cells.

So, yes, I'd say it's normal to expect that to slow your code down ;) Either reduce your layout size, increase the cellsize, or build an alternative routing algorithm that uses a more sparse graph.tanoshimi2013-01-31 13:32:48
B
8
S
2
G
3
Posts: 83
Reputation: 2,668

Post » Thu Jan 31, 2013 2:24 pm

Ah I see, there's no lag when actually in the game which is cool, I'll play with increasing the cell size.

Thanks
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Thu Jan 31, 2013 3:07 pm

It's because it has to collision check every cell on startup to test which are obstacles. As @tanoshimi says that means you're checking hundreds of thousands of cells on startup, so increasing the cell size should help.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Jan 31, 2013 3:58 pm

I haven't had a chance to try out the new behavior, but does that mean that it isn't possible to do moving obstacles, as the cells which can't be passed are calculated at startup instead of on demand or every X seconds (tick would probably be too much :)).
B
5
Posts: 10
Reputation: 822

Post » Thu Jan 31, 2013 5:32 pm

@DancinLion - You can move obstacles, but you'll then need to explicitly call the "Regenerate obstacle map" action before next calculating the route.

Note that this totally regenerates the grid array, so you certainly wouldn't want to do it each tick ;)
B
8
S
2
G
3
Posts: 83
Reputation: 2,668


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 18 guests