Pathfinding not quite working

0 favourites
  • 8 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I've been experimenting with the pathfinding behaviour, and I'm quite impressed with it so far. One hiccup, though, is that it doesn't quite work when you place more obstacles while objects are still moving along a path.

    I've set it so they stop moving, regenerate the obstacle map, and try to find another path, but generally several of them will keep moving along the old path, ignoring obstacles that should stop them.

    I assume this is because the behaviour generates the paths and obstacle maps in the background, but is there a workaround to make sure that the objects don't check for a path until they have the most up-to-date obstacle map?

    Also, I know that regularly refreshing the obstacle map is a bad idea, but I've limited the layout to only 20x20 cells to try and offset any performance issues.

  • I also have this issue with my space game, as I've seen enemy ships fly into asteroids and blow up even though they are updating their paths every second and should be going around.

  • You could use a triggered event when another obstacle enters the view. In your object placement event have a sub event check for pathfinding objects within a specified radius ("find nearest/farthest" or conditional "distance(obstacle.x,obstacle.y,pathfinder.x,pathfinder.y) <= specified radius" ), then the action could be "Object>Pathfinding:Movement>Stop". This will (should!) stop any specified objects currently running along a path to become halted. Good luck!

    Paul

  • Well, the problem seems to be that even after they stop, they will start again after a fraction of a second, still on the wrong path.

    Ashley, does the Regenerate Obstacle Map action have a similar time delay to the Find Path action, or should a Find Path action placed shortly after the regenerate action use the new obstacle map?

  • Sorry for double post, but I seem to have a cheap workaround for the time being. If I use a 'wait' action for a quarter of a second, they seem to do things as they should. I assume, however, that on slower computers that wouldn't be enough time to regenerate the obstacle map so if anyone has a better solution it would be much appreciated!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I agree, it would be nice to have a response from a developer on exactly how this behavior works.

    The more I mess around with C2, the more I realize I have to account for optimization. A lot of the behaviors are absolutely excellent in general, but in making the game look smooth there is a lot of work still to be done. For example, I basically had to manually implement collision using CustomMovement in addition to using the Physics library in order to make my collisions feel somewhat realistic.

  • Personal opinion: I wouldn't use pathfinding at all in the sort of situations it sounds like you're describing. Pathfinding is a strategic planning activity that should be done infrequently to plan high-level movement. As you've discovered, it's expensive and time-consuming.

    Collision avoidance is a low-level, localised movement activity, which is best solved by a reactive steering behaviour such as described at red3d.com/cwr/steer/Obstacle.html

  • thats pretty cool.. is there a .capx for something like this? i would love to see how it works in c2

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