Hey, I am noticing constant frame rate drops and when I profile the game I notice there are stacked calls of BehaviorManager.RunTask() API.
The behavior manager instance is set to Run Every Frame.
The game is turn based so I also tried to manually update behavior trees that I am going to enable but no luck with it. They are just not getting activated.
Here's how I am trying to enable behavior trees so far.
I am coming into a result that these stacked calls ending up with the frame rate drops so I would be really happy if I can learn to workaround this. For a turn based game it should be enough for me to tick and enable behavior once.
Thanks!
The behavior manager instance is set to Run Every Frame.
The game is turn based so I also tried to manually update behavior trees that I am going to enable but no luck with it. They are just not getting activated.
Here's how I am trying to enable behavior trees so far.
Code:
internal async Task StartProcessingBehaviourTreesWithOrderAsync()
{
Warmup();
while (behaviourTreeActivationQueue.Count > 0)
{
taskCompletionSource = new TaskCompletionSource<bool>();
var behaviourTree = behaviourTreeActivationQueue.Dequeue();
var networkedUnitController = behaviourTree.GetComponent<NetworkedUnitController>();
Debug.Assert(networkedUnitController != null);
// Only iterate on AI if it is not stunned or slept.
if (!networkedUnitController.IsAbleToPerformAnyAction()) continue;
behaviourTree.EnableBehavior();
// I tried 'behaviorManager.instance.Tick(behaviorTree);' here but no luck.
ELAPI.Log(
$"Enabled behaviour tree, there are {behaviourTreeActivationQueue.Count} behaviour trees left to activate.",
nameof(AIBehaviourTreeActivator));
await WaitForBehaviourTreeSkipSignal(behaviourTree);
}
}
I am coming into a result that these stacked calls ending up with the frame rate drops so I would be really happy if I can learn to workaround this. For a turn based game it should be enough for me to tick and enable behavior once.
Thanks!