Pathfinding question - relation to scale, distances and complexity.

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • This is a question for more advanced users, or at least for the users who strongly use pathfinding behavior.

    I intend to create a huge layout and use pathfinding on it. Object A will try to chase object B in a complicated maze. It will use pathfinding behavior to do so - any other solutions of navigating and moving would be too complicated to implement, hence the PATHFINDING. Now - the pathfinding solution of route from object A to object B should be fast and done twice a second (it is sufficient for the purpose) because object A and object B are constantly moving.

    Now for the proper question: despite the huge layout and obstacle map in the memory, object A will chase object B only when both are visible on the screen. How does it relate to CPU performance? The question behind is - how algorythm is performing calculations of pathfinding: does limiting distance from A to B gives any benefits? My intuition tells me yes, but I'm curious.

  • The question behind is - how algorythm is performing calculations of pathfinding: does limiting distance from A to B gives any benefits? My intuition tells me yes, but I'm curious.

    Pathfinding (most likely) uses A* Algorithm which generally does get slower the longer the distance between the objects. There's also the possibility that both objects are nearby (on the same screen) but the path between them is a long and complex maze and has to do 3 loops around the whole layout to get there, that will probably also be slow.

    That said, pathfinding works async in an extra CPU thread, so it should not impact performance all that much. It will just take longer for the path to be found.

    I'd say, just test it. Seems pretty simple to set up a testlayout and check how long the pathfinding takes and how it performs.

  • I definitely need a real size prototype to test it. Thanks for the answer!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have used C2 and C3 Pathfinding for a while and I would say it's well optimized, with edge situations bugs having been solved along the way. I used it for quite big layouts with hundreds of objects regularly requesting paths, and it never had any performance impact unless you do huge stress tests. That said, performance considerations should be taken from desktop to mobile.

    Do bare bone stress tests, large layouts, basics sprites, every tick or X seconds and measure performance on various devices.

    Edit : the Pathfinding behavior benefited from the C3 runtime update and you can find Ashley RTS development blogs about improvements. It's reliable.

  • Thanks Nabu

  • You could use the breadcrumb method.

    When A moves it drops an invisible object every x distance from the last, these act as way points.

    When B sees a waypoint it moves to it, then it moves to the next waypoint closet waypoint with a higher value, unless it has direct line of sight to A.

    Waypoints disappear after x seconds so its possible to get away.

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