Pathfinding related issue

0 favourites
  • 8 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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 :

    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.

    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 : dropbox.com/s/d6j5k51y3jlsep6/pathfinding_constructforums.capx

    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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • I didn't quite understand what you meant, but I'll wait until you have time.

  • 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

  • ..

  • ..

  • ..

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)