Performance (on many AIs)

Hi - I purchased the third person animation controller for a multiplayer swordfighting project I'm working on (love the feel of the controller btw).

I have the controller on the player object, as well as on all the AI fighters. I'm hitting performance issues due to when I increase the number of AIs in the scene (right now I'm around 40 but I would like to be able to have 100+). I have attached a screenshot of a frame in the profiler with 40 AIs.

Is this to be expected? If so, do you have a recommendation for a simpler more performant third person controller I can put on my AIs (I'd like to keep TPC on the player since it feels so nice). If not, do you have any recommendations for increasing performance?

Thanks!

2018-11-17_18-13-56 Profiler.png
 
How are your characters moving? If they are with a navmesh you can disable the horizontal/vertical collision detection which will help with performance. The real benefit will come from when the controller is updated to use ECS but this likely won't be for awhile since ECS is still being developed by Unity.
 
I wanted to create a post about it but the search just gave me this.

I'm not even close to 40 AI and have the same issue.
I lose between 10 and 15 fps by AI character added. Just with my main character on a reference test rig (GTX 1080 Ti, Core I7 7700k everything on ultra settings graphic wise) I hit around 110-125 fps. With 5 AI added it drops around 72-80. That's a huge performance hit and nothing is happening out of being IDLE.

I'll test later with proper Navmesh configuration and disabling the h/v collisions, but I was hopping there would be something else to hope for. I know ECS is in Preview but with Unity everything stays in preview for many years now..
 
I was actually able to greatly improve the performance by being more selective with the Collider Layer Mask on the Ultimate Character Locomotion component.
 
I also experienced these big performance hits. I made an AI character so I could have a companion and my fps dropped by 10-15. So I decided to not use the TPC AI creator and just write the AI using Behavior Designer and attaching a Health script to it. That eliminated the performance bottleneck. I will try some of the tips here and see if they work better, but it's definitely a concern.
 
I was actually able to greatly improve the performance by being more selective with the Collider Layer Mask on the Ultimate Character Locomotion component.

I limited it already to my ground (one layer), the regular obstacles (one layer) and the characters (one layer): didn't improve anything
 
How are your characters moving? If they are with a navmesh you can disable the horizontal/vertical collision detection which will help with performance. The real benefit will come from when the controller is updated to use ECS but this likely won't be for awhile since ECS is still being developed by Unity.

Is it helpful to turn down the Quality in the NavMeshAgent component for AI performance?
 
Last edited:
Doing culling on the Animator/CharacterIK component would help a lot. I have it on my list to create a new sorting method so instead of using Array.Sort within the callstack above it will instead do some type of an iterative sort because in most cases it doesn't need to iterate through all colliders. I may be able to get this in version 2.1.
 
Top