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;
destinationSetter.target = 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