From 5048d6a48557ebc7243762895457c5a0e69d374f Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sat, 20 Apr 2024 20:19:07 +0200 Subject: [PATCH] Fix BT being ticked after transition happened and state is no longer active --- bt/bt_state.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index 8497408..b603cfa 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -70,6 +70,10 @@ void BTState::_exit() { void BTState::_update(double p_delta) { VCALL_ARGS(_update, p_delta); + if (!active) { + // Bail out if a transition happened in the meantime. + return; + } ERR_FAIL_NULL(tree_instance); int status = tree_instance->execute(p_delta); if (status == BTTask::SUCCESS) {