Still having performance issues after trying suggestions

For the last week or so I have been focused on performance, the game can run at very high FPS up to when characters start scanning for new paths, “Scan” is the only bottle neck of the entire game taking a massive chunk of memory:

I’ve read many posts and tried to follow suggestions to now luck, performance is always terrible no matter what I do. The game is 2D so I was using Grid Graph and switched to Recast Graph after reading the suggestions and documentation, it took a while to get everything set up but unfortunately my problems persist, and my map is not even as big as I would like it to be, as soon as 15-20 characters are looking for targets the game completely freezes, always because of “Scan” taking 90%-99% of the total memory, these are my inspector settings (which I changed a lot trying to see if anything would help):

Character Settings:

this starts the process but it is only being called once:

    public void SetPathBasedOnPoint(Vector2 newPosition)
        path.canSearch = true;
        seeker.StartPath(transform.position, newPosition);

    public void SetPathBasedOnTarget(Transform target)
        // allows targed search
        path.canSearch = true; = target;

My terrain is divided on squares, to block the path I assigned a NavMeshCut to each square, this is always off by default and I turn it on if for example the player places a building on one of the squares, so the walkable squares are very very clear (of course that doesn’t matter for Recast Graph), it would look something like this:


After a week of trying solutions I ran out of ideas, no sure if I’m doing something silly or if I’m just trying to get too much out of this tool


It looks like you are scanning the graph 23 times in a single frame! Usually you’d only scan the graph once when the game starts. Do you have a particular workflow where you have to scan it that often?

1 Like

Thank you for guiding me on this, I wasn’t aware of that, so that helps a lot with profiling, it had to be me doing something dumb, I will try to figure out where those 23 calls come from and come back to you, maybe with the issue solved.


@aron_granberg found the reason, it was indeed me being stupid, a couple of months ago I added a scan to update some path blockers that happen on certain situations, like when an enemy finds a target and stops to attack it, it is now totally unnecessary and I didn’t even remember it was there, 23 enemies, 23 scans

1 Like