Fix BT being ticked after transition happened and state is no longer active

This commit is contained in:
Serhii Snitsaruk 2024-04-20 20:19:07 +02:00
parent 24382d3fd1
commit 5048d6a485
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
1 changed files with 4 additions and 0 deletions

View File

@ -70,6 +70,10 @@ void BTState::_exit() {
void BTState::_update(double p_delta) { void BTState::_update(double p_delta) {
VCALL_ARGS(_update, p_delta); VCALL_ARGS(_update, p_delta);
if (!active) {
// Bail out if a transition happened in the meantime.
return;
}
ERR_FAIL_NULL(tree_instance); ERR_FAIL_NULL(tree_instance);
int status = tree_instance->execute(p_delta); int status = tree_instance->execute(p_delta);
if (status == BTTask::SUCCESS) { if (status == BTTask::SUCCESS) {