FPS Drop when Enabling AI Agent GameObject

wuche

Member
Hi,

I noticed a severe FPS drop when I enable an AI agent's gameobject. Within the editor, I'm running at about ~120 FPS constant during runtime, but when I activate the AI agent game object, it drops all the way down to 40 FPS. Obviously, this is with editor overhead but this is for a VR game and my goal is to never drop below 90 FPS.

What is the most performant way to initialize an AI agent? Is there a way to preload everything upfront so there is no spike when activating an AI agent's game object? Or is there a better way to introduce an AI agent into the scene?

Please let me know when you can, thank you!
 
Is the deserialization method causing the bottleneck? You should pool the external trees and initialize them doing a loading screen to reduce any spikes:

 
I'm not sure what you mean by the deserialization method but the first time I'm enabling a BD AI Agent during runtime, I imagine the initialization of the managers and the framework in general is causing a brief lag spike.

I'm going to try enabling the first AI agent at the beginning of runtime / loading and then disabling until I need to call on the AI Agent.

Is having external trees strictly better than having native behavior trees? I understand that it allows me to have them pooled during initialization, but are there any downsides to this approach? Otherwise, why aren't all behavior trees external?
 
Is having external trees strictly better than having native behavior trees? I understand that it allows me to have them pooled during initialization, but are there any downsides to this approach? Otherwise, why aren't all behavior trees external?
The one downside is that you'll need to load scene references dynamically, either through overriding variables or through a task/component that runs at the start. This page has more info: https://opsive.com/support/documentation/behavior-designer/referencing-scene-objects/
 
Gotcha, thanks for the replies. I opted for a simplistic bandaid where I have the BD AI Agent pre-enabled before runtime and then have it disabled after the managers initialize (0.1f after Start seems to work just fine).
 
Top