For context, I’m trying to get as many NPCs as possible. The target is 200 NPCs in front of the player with 60 fps. I know the main bottleneck is the skeletal mesh and animation blueprint and have a solution for that (so don’t worry about GPUs). For this post I just want to focus on optimizing the pathfinding logic.
The current method is to connect the “ai move to” node to the event tick and set the class’s “Tick Interval (secs)” to 0.5s. Thus every 0.5s will update the current location that the player is at as the player is moving alot.
Is this a good, performant method or is there a better method?
Like is there an even more simplified method, multithreading, or some how dumping this on the gpu, or some other clever method?
The way to optimize the pathfinding is to not do it so often.
Do it when the NPCs are away from the player and do it rarely - once every 5 sec. You need to get them to the same room or space as the player using PF. Nothing more.
Also you can group close by NPCs, choose a leader and path-find only for them assuming the other NPCs in the group will just follow.
Once close enough just move in a straight line to the player, eventually with some boid avoidance.
This will not solve mazes for you but will work in almost any environment. For 1000+ or very large spaces use flow maps.