odd behavior from pathfinding

0 favourites
  • 6 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hello !

    While using the pathfinding example I noticed a strange behavior. Indeed, in the example (see image), when you move the blue square (solid) in the yellow area, the path changes, even when it is in an area that should not affect it. I don't understand what causes this, there is no exotic code, and yet it refuses to go from the beginning to the end in a straight line. If anyone has an idea or suggestion as to why?

    drive.google.com/file/d/1KvFJtfAnE_aSnZry5_Ckx-G2rjOQQYNK/view

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The blue square is an obstacle. It's trying to find a path around the obstacle.

  • Does the result differ when you change the cell size?

    construct.net/en/construct-2/manuals/construct-2/behavior-reference/pathfinding

  • The blue square is an obstacle. It's trying to find a path around the obstacle.

    Yes has intended, but the obstacle map is small, the same size as the blue square (64px).

    Does the result differ when you change the cell size?

    Nope. The cell size is currently 16 px but no matter the size the result stay the same.

    There is plenty of room for the pathfinder to find a path in a straight line to the green square. But when the blue square's image point enter the yellow one, the path goes from zero node to one node for... reasons.

  • Yeah it's super strange - it seems to happen in all kinds of arrangements between the start/end object. It's also not targeting the precise X/Y of the end object; it's finding a path a little down/right of the origin point.

    Sorry I can't be much help! It feels like a bug but hopefully someone with more experience can see the issue.

  • Hello;

    The pathfinder works in cells, either a cell is blocked or not (or costs a certain number of move points or not). An object might block two cells in one location but only one cell in another depending on overlap. The path goes from the center of one cell to the next in the path it finds, not a straight line. So if you are two cells up and over 3 it has to go over and then up (you can set it to move catycorner which helps a little).

    It doesn't find the path to the object, it finds a path to the cell nearest the center of the object. It starts at the cell closest to your start object. To move exactly to a place you need to use moveTo. Pathfinder only gets you to the nearest cell.

    hope that helps.

    yours

    winkr7

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