Pathfinding doesn't arrive at exact location?

0 favourites
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • How I do it is by checking frequently for line of sight to the destination, and when the sprite has it I stop the pathfinding behavior and start the moveto plugin.

    I didn't think of that, but I am currently using the On Arrive event to then kick in the Move To command (previously was a Set Position). It looks slightly instant, which might give the feeling of "snapping". It isn't too bad though and might actually fly by as a feature.

    Maybe another way would be to create/spawn a 1pixel transparent sprite on mouse click ..then set the 1pixel sprites position to the clicked object.X,Y origin within the same event..

    -->

    Then 'find path' to the 1pixel sprite.x,y

    and destroy the 1pixel sprite after pathfinder arrives at destination

    that might work a little better

    also If you needed to find paths to moving objects then you would just add a pin behavior to the 1pixel sprite which is pinned to object at initial mouse click

    It is a stationary object that I am moving towards. This might actually work, albeit I feel this is more of a bug in Construct 2 (r229 is what I am using) more than anything else. I doubt the intended use of "Find a path to an object's X and Y position" would just end when it reaches the general abouts of the X and Y.

  • What happens if you set the pathfinding cell size to be the exact same as the actual object doing the pathfinding?

    Eg. if your object is still set at 5px, make the path cells to be 5px also... just wondering what would cause it to suddenly stop when it gets "close enough". It has to be something between the actual object bounding box size, and the pathfinding cell size.

    ~Sol

  • What happens if you set the pathfinding cell size to be the exact same as the actual object doing the pathfinding?

    Eg. if your object is still set at 5px, make the path cells to be 5px also... just wondering what would cause it to suddenly stop when it gets "close enough". It has to be something between the actual object bounding box size, and the pathfinding cell size.

    ~Sol

    There is nothing on the layout between the two. I only have 3 objects on the layout as you can see below; the moving object is created on run time and immediately moves to one of the two objects (that have the green object). The moving object is created on the cyan/light blue square.

    The result above is when I increased the cell size to the same as the object moving. As you can see, not much difference.

  • Hmmm, this must be a "quirk" of the pathfinder movement - it just gives up when it's "good enough". Probably to do with speed/optimisation of the behaviour most likely.

    I guess doing something like Arima suggested, using LOS and then simply "moveto" once LOS has been achieved. You can set your LOS distance to be fairly close to the object itself and it should give the desired result.

    I think maybe I should play around with pathfinding a bit more and see if there is some other way, but that method sounds pretty good to me in theory.

    ~Sol

  • Hmmm, this must be a "quirk" of the pathfinder movement - it just gives up when it's "good enough". Probably to do with speed/optimisation of the behaviour most likely.

    I guess doing something like Arima suggested, using LOS and then simply "moveto" once LOS has been achieved. You can set your LOS distance to be fairly close to the object itself and it should give the desired result.

    I think maybe I should play around with pathfinding a bit more and see if there is some other way, but that method sounds pretty good to me in theory.

    ~Sol

    Should I file a bug report or anything of the sort so Ashley could check it?

    Right now I am using a check with distance() and having the Move To take over as I feel LOS is a bit of an over kill, but I might actually end up using it as you mentioned since it may make the movement appear more "fluid".

  • I also have noticed this with path finding movement and decided to use other behaviors (may not be possible in all situations)

    I had a player move towards enemy on path finding movement and had an event for on collision to attack (since enemy was still moving I didn't want to wait for arrival and have them walk past each other). Sometimes it would "arrive" at the enemies origin but wouldn't be close enough to cause collision.

    Also had zombies that were supposed to take a few steps at a time so it was path finding a small distance. Randomly it wouldn't move at all when it was supposed to. I could never trouble shoot it. I guess now I know it was "close enough" so didn't move at all.

    I know this post doesn't help you but I am interested in any resolution as right now path finding movement is my last choice, unless there is an actual maze.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I guess it can't hurt filing as a bug. If it is intended behaviour then Ashley will know and just close the report. If not then he will fix it at some point

    ~Sol

  • I also have noticed this with path finding movement and decided to use other behaviors (may not be possible in all situations)

    I had a player move towards enemy on path finding movement and had an event for on collision to attack (since enemy was still moving I didn't want to wait for arrival and have them walk past each other). Sometimes it would "arrive" at the enemies origin but wouldn't be close enough to cause collision.

    Also had zombies that were supposed to take a few steps at a time so it was path finding a small distance. Randomly it wouldn't move at all when it was supposed to. I could never trouble shoot it. I guess now I know it was "close enough" so didn't move at all.

    I know this post doesn't help you but I am interested in any resolution as right now path finding movement is my last choice, unless there is an actual maze.

    Well I have been using an "On Arrived" + "Move To" to get the moving object to reach the center of the target. It doesn't feel natural if you really concentrate (doubt players will notice if they are engaged). It is good for now though as I haven't gone for polish yet.

    I guess it can't hurt filing as a bug. If it is intended behaviour then Ashley will know and just close the report. If not then he will fix it at some point

    ~Sol

    Done, I filed a bug report and hopefully it will be fixed with one of those updates

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