How can I make AI have less impact on performance?

You guys can run more than 20 AIs at a time? Been asking around and everyone pretends Character Movement is the best thing ever and telling me to remove function calls from my tick events when I don’t have anything running on tick. Even with no AI my own character lags if you move around too quickly for more than 10 seconds.

2 Likes

well helped in 2024 too :smiley:

For basic ai where youre not using a behavior tree, you can remove all char movement components
/pawn sensing and add a set timer by even at begin play. Have this timer do the same thing as “onSeePawn” for enemy AI. The update time on the event timer is comprable to tick, however you can update at something way more performant like .5 seconds and still see pretty smooth action from the AI. Assuming that this is basic AI without blackboard and b(x) tree, this method is way more performant. The other large problem here is spawning AI. This requires an aggressive amount of resources and is better acomplished by having the enemies already stored in an array so they are already loaded in. Ive yet to perfect this but the timer by event saves a lot of performance by itself.

1 Like

Unfortunately the pathfinding in Unreal is offering terrible performance. At about 50 AI (very basic, I give it a target and then do a Move To Location or Actor function. When they all try to pathfind to the same target is where the performance drops massively. To get a bit better performance is to increase the recastnavmesh tile size and cell size, which makes the navmesh less accurate and on tight spaces it will not even generate navigation.

If anyone has a solution to that I’d love to hear it.