[Path finding] Inaccurate results

0 favourites
  • 2 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • Problem Description

    Not sure whether this was a bug or not at first, im now pretty sure that it is not working as intended.

    The problem is that the path finder give you wrong results regarding whether a path can be found or not. And that the calculations or way It figures out what cell is the best alternative is not working correctly as it ends up selecting invalid cells even though others are valid.

    Here is a short example:

    Shows the starting position of the unit. And the big green square is a solid.

    If the unit is told to move to either the left or top side it will work fine.

    But when told to move to right or bottom side it fails.

    Doing some testing it seems to indicate that these two sides have some problems, as moving the starting position doesn't have any effect.

    Result in the same problem

    It seems to be that a target destination to an empty cell near the original target when its a solid is not found correctly and therefore gives you wrong results.

    Using the above example where the unit is starting above the big green square, the possible paths to the destination and the best possible path (indicated by the red square) to the target would be like this, so there should be no reason for it to give you a path not found.

    Description of Capx

    Will just path find to a selected target. chosen by left mouse button.

    Steps to Reproduce Bug

    Click any of the solid tiles on the right or bottom side.

    Observed Result

    Will give you the result that no path could be found.

    Expected Result

    That it finds a path to the best nearest empty tile that it can reach.

    Affected Browsers

    All

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    r185

    Don't think it have anything to do with this version as I believe this problem have been there for a very long time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • UPDATE:

    I modified the program a bit, so it works now. However the solution is not really perfect or optimal I think.

    But the idea is to add what I call "Path mesh" in lack of better words. Which is indicated by the red tiles.

    Checking where this mesh is placed in relation to the solid target, it can find the correct path to any of the sides, except diagonal as I haven't made that. But in cases where there are mesh in both directions, it rely on the path finding to fail to find a path so it can check the other cell. Which ofc shouldn't really be needed and this way of doing it will require a lot of correctional code to make it work under all possible circumstances I could imagine if it was a bit more complicated setup.

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