fix: enter/exit get called in hierarchy order

This commit is contained in:
Sara Gerretsen 2026-03-12 23:07:51 +01:00
parent 5b9d437600
commit f64f126f45

View file

@ -40,10 +40,13 @@ bool BehaviourTree::execute_next() {
return false;
} else {
ERR_FAIL_COND_V_EDMSG(next == nullptr, false, vformat("%s::get_next returned a nullptr, repeating last node", this->current->get_class()));
print_line("new behaviour:", next->get_path());
this->current->exit();
if (this->current != next->get_parent()) {
this->current->exit();
}
if (this->current->get_parent() != next) {
next->enter();
}
this->current = next;
this->current->enter();
return cast_to<BehaviourComposite>(this->current);
}
}