A) Running smoothly on Android and b) Generating grids

I currently have the free version of this A* pathfinding set up with Unity Pro.

I modified the example terrain scene with a terrain that I generated from a height map. The height map that I used is a floor plan of a building so pathfinding could be 2D so maybe using the terrain scene is doing unnecessary calculations. If it’s more efficient to use a predetermined grid, how do I calculate one for my scene automatically? I saw there’s a generate grid / mesh script but they can’t be attached to objects so not sure how they’re used.

I have a total of 16 characters and four targets which they follow in groups of four. The targets change position every 15 seconds (staggered so the four targets move at 3.75s intervals). I edited the scripts so that repathing only occurs when the targets move as opposed to every 0.2 seconds as it was by default but that didn’t increase framerate much.

I get about 50fps on PC, but on mobile it’s too slow to consider moving. I’ve tried turning things off wherever possible, such as collision testing, to see if that helps, but can’t get it higher.

Any advice will be greatly appreciated.

Hi

Have you profiled your game?
If the paths are only recalculated every 3.75 seconds, it is likely not pathfinding that is the problem. Try to profile the game and see what exactly is using all the CPU (or GPU) power.
I have heard people using that many characters on mobile and it has worked fine for them.

It turns out my terrain was made up of millions of triangles despite being a fairly basic shape! I exported it as an obj with downgraded resolution and it’s now less than 70k triangles and the game runs a lot smoother. A mobile test shows over 60fps now.

Well, there’s your problem :stuck_out_tongue:

Awesome that it works now!