Fix crash when looping BT with Force Success node

This commit is contained in:
2026-09-24 23:38:50 +02:00
parent 0d4ea64caa
commit 0c63c91a7d
2 changed files with 18 additions and 7 deletions
+16 -7
View File
@@ -107,16 +107,25 @@ void Behavior::UpdateAsync()
context.DeltaTime = updateDeltaTime;
context.Time = _totalTime;
const BehaviorUpdateResult result = tree->Graph.Root->InvokeUpdate(context);
if (result != BehaviorUpdateResult::Running)
if (_result == BehaviorUpdateResult::Running && result != BehaviorUpdateResult::Running)
{
// Update result
_result = result;
if (_result != BehaviorUpdateResult::Running && tree->Graph.Root->Loop)
{
// Reset State
_result = BehaviorUpdateResult::Running;
if (_result != BehaviorUpdateResult::Running && tree->Graph.Root->Loop)
{
// Reset State
_result = BehaviorUpdateResult::Running;
}
else if (_result != BehaviorUpdateResult::Running)
{
// End
Finished();
}
}
else if (_result != BehaviorUpdateResult::Running)
else if (_result != BehaviorUpdateResult::Running && tree->Graph.Root->Loop)
{
Finished();
// Restart on end (eg. after Force Success node during Update)
StartLogic();
}
}