Pathfinder Object not following path / refusing to move

From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.

    Hi, I'm having some real troubles with the pathfinder behavior here. The path finding part seems to be working perfectly fine:

    The green square is a solid object and the red arrows (taken from tutorial to mark path) has properly created a path towards the target (based off turret behavior and nearest target).

    however when it actually starts moving (it also doesn't move immediately it takes it like 3 seconds even though the path has already been found) it completely ignores it and runs straight and then gets stuck inside the green square solid.

    Not to mention, depending on where you put the object with pathfinder it won't even move at all.

    (pathfinder object is just stuck there)

    (debug shows the path is found and object is moving BUT speed is 0, trying to change it does not work at all and trying to add a change speed (e.g 200) to the event for when path found --> follow path doesn't do anything at all)

    Here is the pathfinder code im using

    The catchall to make units move

    The function to determine what the path target is

    and lastly the function for setting up the objects with pathfinder (not sure if this one is relevant)

    Sorry, it seems my debugging screenshot was cut off, heres the full pathfinding info

    puu.sh/Ffijf/80d313bf27.png

    (not sure why forum won't let me add anymore pictures?)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads

    Make sure that your "Find path" action is only triggered once, and not on every tick. You can add "Browser -> Log" debug message, then in preview press F12 and open browser console, you should see this message appear once.

    Maybe there is something else preventing the Adventurer from moving. Does it have any other movement behaviors, like MoveTo, Physics etc.? Check if pathfinding speed is set in behavior properties.

    If nothing helps, please share your project file, as I don't see any problems on your screenshots.

    Make sure that your "Find path" action is only triggered once, and not on every tick. You can add "Browser -> Log" debug message, then in preview press F12 and open browser console, you should see this message appear once.

    Maybe there is something else preventing the Adventurer from moving. Does it have any other movement behaviors, like MoveTo, Physics etc.? Check if pathfinding speed is set in behavior properties.

    If nothing helps, please share your project file, as I don't see any problems on your screenshots.

    I couldn't figure out how to setup the browser log debug (made the event and log but what am I suppose to enter for the message?) so I just set it so the find path only triggers every x seconds but that didn't seem to help.

    There is no other movement triggers on the Adventurer object other than pathfinder

    my project file is: dropbox.com/s/fylp04pa2mims8k/pathfinding_help.c3p

    thanks

    made the event and log but what am I suppose to enter for the message?

    Whatever you want. For example, Log "Adventurer "&Adventurer.UID&" FIND PATH"

    Then open browser console in preview and watch for this message.

    .

    The problem is Turret behavior, it somehow prevents Pathfinding from moving. I'm guessing it tries to change the angle.. If you disable Turret immediately after "Find path", then the adventurer moves correctly. Try using a different sprite for turret behavior, pinned to the Adventurer sprite.

    Also, using Solid on the same Adventurer sprite can cause problems, don't do this. Same with adding Adventurer sprite to obstacles.. If you want to prevent multiple adventurers from bumping into each other, this is not the right way to do it.

    Check your cell size, reduce it if necessary. Check the cell padding as well, I believe it defaults to -1, which could allow your object to move into a wall and have overlapping problems. If you're using move along path to move your object, try increasing your rotation speed from 100 to 1000 or even higher - this will let you get more direct movement between nodes, depending on the scale of your project and speeds involved.

    > made the event and log but what am I suppose to enter for the message?

    Whatever you want. For example, Log "Adventurer "&Adventurer.UID&" FIND PATH"

    Then open browser console in preview and watch for this message.

    .

    The problem is Turret behavior, it somehow prevents Pathfinding from moving. I'm guessing it tries to change the angle.. If you disable Turret immediately after "Find path", then the adventurer moves correctly. Try using a different sprite for turret behavior, pinned to the Adventurer sprite.

    Also, using Solid on the same Adventurer sprite can cause problems, don't do this. Same with adding Adventurer sprite to obstacles.. If you want to prevent multiple adventurers from bumping into each other, this is not the right way to do it.

    Thanks that looks like it fixed it, I guess ill have to create a third sprite for each adventurer... but I guess theres not much i can really do about it. Also, you said that making each adventurer sprite a solid is not the right way to stop them from bumping into each other, what would the proper way to stop them from stacking/fusing on top of each other?

    Check your cell size, reduce it if necessary. Check the cell padding as well, I believe it defaults to -1, which could allow your object to move into a wall and have overlapping problems. If you're using move along path to move your object, try increasing your rotation speed from 100 to 1000 or even higher - this will let you get more direct movement between nodes, depending on the scale of your project and speeds involved.

    Yup, looks like the cell padding was set to -1, changing it seems to have fixed that overlapping issue. Thanks!

    what would the proper way to stop them from stacking/fusing on top of each other?

    Unfortunately, there is no proper way. There are many methods, but none of them work 100% correctly. You can search this forum for something like "pathfinding no overlapping". Also, I have two demos which are a bit complex, but may give you some ideas:

    howtoconstructdemos.com/avoid-overlapping-while-moving-with-pathfinding

    > what would the proper way to stop them from stacking/fusing on top of each other?

    Unfortunately, there is no proper way. There are many methods, but none of them work 100% correctly. You can search this forum for something like "pathfinding no overlapping". Also, I have two demos which are a bit complex, but may give you some ideas:

    https://howtoconstructdemos.com/avoid-overlapping-while-moving-with-pathfinding/

    Ill look into those demos, thanks again for all your help!

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