fix: enter/exit get called in hierarchy order
This commit is contained in:
parent
5b9d437600
commit
f64f126f45
1 changed files with 6 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue