Good job but, performance killer.

Yzack

New member
Hi,

I've downloaded the character controller integration package for Behavior Tree.

Although i'm impressed with the quality of these two assets, good job!, i'm disapointed.
I think i will not be able to use the Third Person controller (for AI NPCs) in my VR game.

My need : 5 NPC in view simultaneously.
But got a huge framerate drop, too much -> The deterministic component took about 8ms itself which is already the max global time for 90fps VR needs.

I've just duplicate the "nolan agent" 4 times in the demo scene, so i doubt I did something wrong.

- Lightmapping Baked
- Navmesh Baked
- No console log / errors

1) I did forum research, someone say (Justin if i remember) : "try to deactivate horizontal/vertical collision detection, it can help". but the agent fall through the ground if deactivated
2) Select layers in the layer manager does not seem to be very influential (for me)
3) Culling update transform is non-sense for the case "I should see 5 npc".
4) buying a new computer is not an option :) (it's reaching the VR requirements)
5) See someone saying "disable IK should help" (not for me but maybe it's something different than just delete the opsive IK component from npc's ?)
6) Don't need deterministic -> solo game -> This where, maybe, i should be aware.

I've already self made AI humanoid npc for my game, and can have very good results with 10, so unity animations "should" handle the job (but much, much, less versatile than your product, of course, that's why i purchased Opsive solutions).

Did i miss something ? Did i screwed up somewhere ?

TPC_BD_integration.PNG
 
It looks like your bottleneck is updating the animator, which unfortunately the controller doesn't have much control over.

Within the animator the IK portion is taking the longest. As a test if you disable the CharacterIK component and also the IK Passes on the animator does it get any better?
 
Last edited:
Yes, disabling the characterIK component and also the IK passes on the animator help getting things faster : from about 8ms to about 3ms.

On my point of view, there is a little bit too much overhead in the deterministic manager.
Maybe it's necessary for the TPC objectives and modularity, but for example, on my side i can move 8 IK humanoids npc with 0.77ms FixedBehaviorUpdate based on standard Unity animator.

I've read another forum post where you were talking about the Deterministic manager performance.

I understand there is nothing more to do at this point and appreciate your help, and i hope, maybe if possible some improvements about tgis in a next upgrade.



Ik_deactivatedPNG.PNG
 
The next version does improve one piece of the collision detection portion pretty dramatically (reducing it by 60-80%). If you also change the fixed timestep you can also reduce the number of times that the controller updates.
 
Sorry, even i close the thread, one last question :

When can i expect the next improve version ? Not a date but : in few weeks, middle year, end of year ?
Thanks for your answer, it will be easier for me to make a decision on BTD integration.

Best regards,
 
I also see that the DeterministicObjectManager is a bottleneck. I already have CharacterIK off, but at ~3ms performance cost, it does impact my scene far more than I would like on the Wii U. My game right now is struggling to stay close to my 30 fps budget and I think if this component can be improved then it would definitely help. I'll try changing fixed timestep to see how that helps, but looking forward to the 60%-80% improvement that you mentioned. Do you have an ETA yet on 2.1?
 
Just to be clear - the 60-80% improvement is within one part of the collision detection code (the line will be listed as Array.Sort within the profiler window under DetermineHorizontal/VerticalCollisions). But we hope to be able to get 2.1 out in the first part of February.
 
The current version has many performance improvements compared to the version that was out in January. Allowing the animations to be updated using the jobs system should be a huge boost. I would try it again with the latest release and profile to see what bottleneck you are hitting.
 
The current version has many performance improvements compared to the version that was out in January. Allowing the animations to be updated using the jobs system should be a huge boost. I would try it again with the latest release and profile to see what bottleneck you are hitting.
Yes, good to hear, although I have the latest version.

I guess I installed the jobs package as well just in case. But still, no decent framerate:
1187
 
It seems to be Animation CPU usage. As a disclaimer, I'm an artist, not a programmer so I have some limits to understand what's going on.

1197
 
I have a solution for those that are interested.

Here is an example of the results that I was able to achieve by using GPU instancing and baked skinned mesh rendering , my goal was to have a max of 200 AI units using the Ultimate character controller plus my own character. On the left was my first attempt using the out of the box mecanim animator and the Ultimate character controller with the AI agent, the result was a dismal 0.4 FPS. This is not acceptable so I implemented GPU Instancing which you can see on the right. This resulted in around 70 to 80 FPS which in my book is acceptable.
example.jpg

If you would like to achieve these results here is how I did it. but first let's start by looking at the bottlenecks that are causing the huge framerate drops. The first problem area is the ik component which you can disable, the second problem area is the character locomotion component which I ended up rewriting to be more simple and use less stuff ie (when the player is not looking or when the AI unit is far away.)
The last problem area which is also the biggest problem has to do with unity's Mecanim Animator. To fix this you will need to implement GPU instancing, skinning techniques and also implement your own simplified animator (optional).

If you want to implement these yourself you can take a look at this blog post from unity which will point you in the right direction https://blogs.unity3d.com/2018/04/16/animation-instancing-instancing-for-skinnedmeshrenderer/

For myself I just use these two tools from the asset store, they are little pricey but they do save you the hassle of implementing everything yourself.
GPU Instancer - Crowd Animations https://assetstore.unity.com/packages/tools/animation/gpu-instancer-crowd-animations-145114
GPU Instancer https://assetstore.unity.com/packages/tools/utilities/gpu-instancer-117566

I hope this helps anyone else who is running into problems and would like to increase their FPS while using Ultimate character controller with their AI. I will note that to achieve these results you will need to do a far amount of learning/work. I would suggest that creators of Ultimate Character controller look into implementing their own GPU instancing and skinning techniques or integrate GPU Instancer to work with their controller. These changes would greatly add to the utility and usability of the character controller and the integration package for Behavior Tree.
 
Last edited:
Hey! I got the controller and behavior designer set up and integrated, it looks great in my demo scene with just two agents and my character! But I'm having a similar issue to these other posters, I tested a scene with 20 AI Agents with the demo behavior and setup (newest version, on fixed update and no IK) and the performance took a steep dive even on the new fancy computer I just built. I will be having many different meshes for NPCs and enemies so I am implementing a instanced mesh renderer but it wont help me too much. Has anyone found a good solution to removing some of this unnecessary overhead when applying the controller to their AI? Especially for NPC units that wont be in combat so don't need nearly as many colliders and complications. Thanks! The controller and behavior designer seem like a perfect solution to my problems except when it comes to scaling for crowds, I'm hoping I can figure this out soon so I can use it

(I know there are simple things I can & will do to help performance like decreasing the size of the animator file, that's not really what I mean)

1589298799024.png
1589298807895.png
 
On the Ultimate Character Locomotion component you can disable the horizontal/vertical calculations which will reduce the time. Setting the update mode to Update should also help. Ultimately though the real performance gain will come when we switch to the jobs system but this is still a ways away.
 
Thanks Justin! I'll give that a try and I am looking forward to the job system switch I think that would solve a lot of my problems for sure. Keep up the great work, I really love both of these products so far
 
Top