How to use Pathfinder efectively?

0 favourites
  • 3 posts
From the Asset Store
A short demo of template sold on store, with formations on end of way for no overlaps.
  • Hi

    I�m experimenting with the pathfinder behavior, and have found it can cripple the CPU. I�m doing an RTS, and as soon as the unit number gets slightly high (around 20) the frame-rate drops to it's knees.

    My guess is I'm not using it efficiently, but I have not found examples of tutorials on how to use it well; how to use it so that it doesn't melt the CPU.

    Any thoughts?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What setup do you use ? Grid size ? Do you have any moving obstacle and/or regular "regenerate obstacle map" ?

    Once the obstacle map is generated, paths are computed on demand, and a path asked multiple times is search only the first time (it directly triggers the OnPathFound next times).

    If you have a path finding on every unit, and if every unit is itself a moving obstacle, and all move simultanously, yes, your CPU will melt. I will then melt again, and again, just to say it's not happy.

    Moving obstacles in particular are a biiiiig hit on the FPS as they disable the behavior's "cache".

    Knowing more on your game could help detect the problem though.

  • I'd be interested to know more about your project, too.

    I built a quick test with grid size set to 16 and a room filled with moving solid objects. It generates a new pathfinder object every 0.25 seconds and every object gets a new unique path every 1 second. I watched it climb to 300 objects before I got bored, and by then it still sat solid at 58-60fps.

    I did notice that when the grid size dipped to around 8, I got stutters every second, but I can't imagine that anything less than 16 would be required.

    Even 32 would work fine in an RTS. Consider the grid-based construction of even a modern RTS like Starcraft II - that goes a long way to assist in speeding up the engine.

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