Pathfinding related issue

Get help using Construct 2

Post » Mon Feb 08, 2016 9:27 pm

I had an idea for a game concept that I'm creating right now, and... well it doesn't work the way I wanted.
First, let me explain my idea.
I have some kind of building simulation game project, and I wondered how I could check that House A is connected by the road to Service A, for example. Before you tell my how you'd have done this, I figured something out but it involves pathfinding, something I'm not familiar with at all. Here is it :

Image

Here, the grey tiles are roads, H are houses, and W is the service. Two houses should be considered as "connected" to the service tile, and two shouldn't.That's what I wanted to do.
So, I generate solid objects by the edges of the tiles, and destroy the ones between two roads or between a road and a H or W tile.

Image

Then, I could find a path between the Houses and the service. But whatever settings for pathfinding I use, the houses keep ignoring the obstacles. I searched everywhere and the documentation about pathfinding is quite hard to find IMO.
So here I ask for help. I have two questions:
1. Is it a good idea to check connection between to objects through other objects using the pathfinding behavior?
2. And more important, why is it not working?

Here is the download link for the capx file : https://www.dropbox.com/s/d6j5k51y3jlsep6/pathfinding_constructforums.capx?dl=0

Use the mouse and the H, R and W keys to create Houses, Roads and Wells. I added a "follow path" action for testing purposes, but of course here I'm only interested in the "find path" action.
B
3
Posts: 3
Reputation: 186

Post » Tue Feb 09, 2016 5:02 am

Hello, I will have to play with the code.

But believe you could add some thing like if overlapping road move along path and if not overlapping road find path or recalculate path.

will play around with it tomorrow as I am tried and going to bed.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Tue Feb 09, 2016 6:26 pm

I didn't quite understand what you meant, but I'll wait until you have time. :)
B
3
Posts: 3
Reputation: 186

Post » Wed Feb 10, 2016 11:06 pm

Ok! here is the first issue I found.

on start destroy all (items) House, Road and Well blocks.
as on creation of house set move to wellblock = run off screen.

set pathfinding cost to canvas or area blocks so that road is less resistance, so that house moves along road before canvas unless no road is created.

edit 1: This would be if you where to use area blocks to cover the play area.

on click
for each areablock (destroy area block) and create item house, road or well

if area block = solid = no path unless you create road.
area blocks can be set to invisible and only you would know they are there.

think of it like dig dug where you had to dig a path to get to a location.
thus also like enemies crossing the un-dug areas pathfinding cost = higher and bug out areas = no cost.

edit 2: also you would have to disable move at angles and use snap to grid as if you create house between grids there would be overlapping issues with move along path. I noticed this issue when creating my point and click demo as path finding area needs to be set to 2-5,2-5 smaller then the block size to move freely along path.

edit 3: it's not perfect but here is a mod of your file
https://www.dropbox.com/s/vs6g34gqdq0bt ... .capx?dl=0
Last edited by Carbincopy on Fri Feb 12, 2016 8:58 pm, edited 3 times in total.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Wed Feb 10, 2016 11:11 pm

..
Last edited by Carbincopy on Fri Feb 12, 2016 8:56 pm, edited 1 time in total.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Wed Feb 10, 2016 11:23 pm

..
Last edited by Carbincopy on Fri Feb 12, 2016 8:57 pm, edited 1 time in total.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Thu Feb 11, 2016 2:33 am

..
Last edited by Carbincopy on Fri Feb 12, 2016 8:58 pm, edited 1 time in total.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Fri Feb 12, 2016 6:48 pm

Ok, thanks for your answer, but I cannot work on this right now, so I'll try as soon as possible !
And again, thanks for your help.
B
3
Posts: 3
Reputation: 186


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983, KTML5, superzenmachine, tarek2 and 3 guests