Performance optimization when EnableBehavior

meichen8050753

New member
I load ExternalBehavior from pool and starBehavior with BehaviorTree.EnableBehavior();

But I found that everytime when I call BehaviorTree.EnableBehavior(), I must BinaryDeserialization form ExternalBehavior, Even they has same ExternalBehavior.

If I start with 20 monsters It will make a serious stuck and lot of memory alloc. (eg. 20mb at once)

I tried AsynchronousLoad but can't avoid memory alloc.

This is the profile one of monster AI enabled when game statrt.

Hierarchy.png


that has any way start multiple ai from same externalbehavior fast and cheap ?
 
You should deserialize the external trees during a loading screen. Take a look at this page:

 
You should deserialize the external trees during a loading screen. Take a look at this page:

thanks for your replay

I deserialized ai during a loading screen of course.

In my case, If I load ai cost 2 or less sec that will perfect, But in my case it cost 5-7sec in MSM8998 or more in lower.
 
When you use the object pooling method you are transferring the deserialized tree. After the tree is deserialized the tree then has to be initialized, which is also run within EnableBehavior. This initialization process is not transferable as it contains references to the specific tree.

Another method that you could try is instead of pooling the external tree, you instead pool the AI agents. This will allow you to deserialize and initialize the tree, making the startup immediate. To do this you would call EnableBehavior on the agent during the loading screen, and then call DisableBehavior immediately. By calling disable behavior you are keeping everything in cache so when the same agent starts up again it will be immediate.
 
Top