Pathfinding Bug? Not Seeing Obstacles

0 favourites
  • 4 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • I have been fighting with Pathfinding and it has been totally keeping me from progressing in this game, its extremely furstrating.

    Here is the code.

    It was working just fine, no problems. Then I add something totally unrelated to pathfinding and now when I test the game the Enemy just walks right through the rock1, when before they would walk around it as expected. The only thing I added after the pathfinding was working is the code at the bottom that is disabled which should not have any affect on pathfinding I don't think.

    The last version of the game did the same thing and the only way I could get it working again was to delete all of the obstacle objects, delete pathfinding, re-add objects, and re-add pathfinding. I don't want to get 90% through the game and run into this problem again where pathfinding just decides to stop working and I have to start over again. Any ideas? Could it be that I am using a beta branch of Construct 2 (Release 231) ?

  • Just started over and recreated it in Stable release and can verify its doing the same thing. Double checked to make sure obstacles were set to custom, rock1 does not have a solid behaviour, and collisions are enabled on the rock1.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Allow me to make a wild guess, all in the mind of: Could it be the case that .....

    So ... could it be that you started with solid rocks and the pathfinder on default obstacles: solid. Then you changed to custom obstacles. Added them in the 'on start of layout', and it worked.

    Well somewhere (on a dark place where i can not bring my dull brain) there is a obstacle map. And there is only one. Meaning, it is not private/instance or object. This map is catched, for performance. So when you (in the could it be that case still) changed to custom obstacles, this map was still catched by the browser. But that did not rest that long.

    Your current (the one shown above) events can not work at all. Because you forgot to use the action sprite > pathfinding > Regenerate obstacle map directly after adding the obstacles.

    Dont forget: if you move a rock. You should use 'Regenerate region around object'. And find new paths.

  • I think I figured out how to make it work although I am not positive if this is how its supposed to work

    I got it working by adding the add obstacle to the on-create event for the Enemy family.

    Enemy, On Created ----> Add Pathfinding Obstacle rock1

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