Help with city-building grid, runtime road tool, & performance

Hey all,

I’ve been trying for months now various methods to make a standard runtime road tool for a square grid (like those in Caesar3, Pharaoh, Zeus & Anno series) - nothing fancy.

So far, I’ve made an A* BP-based path system, but no matter what I populate its arrays with (ints, 2Dvectors, DataOnlyActors) the algorithm is sluggish and kills performance. Too many iterations I guess. Besides, trying to make a city-building game means large grids (10K+large - and that’s for a medium-sized map). Here, I also have a performance problem…

Am I missing something? Are there any marketplace/3rd party tools for efficient large grids and/or runtime road tools?

What I’ve picked up so far is that BP is the main problem. Regarding this, do you think that C++ code running the same Grid+Alg. would perform THAT much better? Is it BPs or something else? Am I doing something wrong? How are those damned road tools and huge grids coded in games from the 90s?

I have absolutely no knowledge on C++ or any other programming language, I’m only decent with BPs.



Hi Claudiu,

I’m curious if each road section is its own actor or is added to one actor?

Also, have you tried any performance profiling? It would be helpful to know where the bottleneck is that is causing the slowdown. Here is the documentation link if you haven’t had a chance to look through it yet:


  1. The road tool I did was simply instanced static meshes being spawned by a “road tool BP”. I think this is “the way to do i” since spawning an actor for every single tile would mean some thousands of actors spawned just as placeholders for the mesh, maybe a collision volume and/or some data. So, using instanced SMs with physical material (if you also need collision) seems for me the way to go - I may be wrong though.
  2. Yes, I’ve profiled the algorithm, and (obviously) neighbor-checking function has a huge impact on performance, but I can’t say other functions which involve iterating through the whole grid perform better…You know iterating through big arrays on tick (or even .2 or .5 secs) is going to impact performance.

What I don’t know is how did those old games manage to run pathfinding on huge grids (remember Impression Games’ Pharaoh) on a 200MhZ CPU… What I suspect is that I’m doing something terribly wrong, or it’s just Blueprints. Maybe in C++ the same code would run faster? In that case, I need to find and pay someone willing to code the C++ functions and expose them to BP so I can use the system or something…

Any ideas?