diff --git a/modules/behaviour_nodes/behaviour_action.cpp b/modules/behaviour_nodes/behaviour_action.cpp index 0351a74cd6..34b607227c 100644 --- a/modules/behaviour_nodes/behaviour_action.cpp +++ b/modules/behaviour_nodes/behaviour_action.cpp @@ -9,11 +9,13 @@ void BehaviourAction::_bind_methods() { } void BehaviourAction::enter() { - GDVIRTUAL_CALL(_enter); + Status out_status{ get_status() }; + GDVIRTUAL_CALL(_enter, out_status); + set_status(out_status); } void BehaviourAction::execute() { - Status out_status{ Fail }; + Status out_status{ get_status() }; GDVIRTUAL_CALL(_execute, out_status); set_status(out_status); } diff --git a/modules/behaviour_nodes/behaviour_action.h b/modules/behaviour_nodes/behaviour_action.h index 8f61a5d0d1..b9608a708f 100644 --- a/modules/behaviour_nodes/behaviour_action.h +++ b/modules/behaviour_nodes/behaviour_action.h @@ -11,7 +11,7 @@ public: void execute() override; void exit() override; BehaviourNode *get_next() override; - GDVIRTUAL0R_REQUIRED(Status, _execute); - GDVIRTUAL0(_enter); + GDVIRTUAL0R(Status, _execute); + GDVIRTUAL0R(Status, _enter); GDVIRTUAL0(_exit); }; diff --git a/modules/behaviour_nodes/behaviour_tree.cpp b/modules/behaviour_nodes/behaviour_tree.cpp index 78bd209fca..2aed80a598 100644 --- a/modules/behaviour_nodes/behaviour_tree.cpp +++ b/modules/behaviour_nodes/behaviour_tree.cpp @@ -7,10 +7,9 @@ void BehaviourTree::_bind_methods() {} void BehaviourTree::process() { - this->current->execute(); - while (execute_next()) { + do { this->current->execute(); - } + } while (execute_next()); } void BehaviourTree::_notification(int what) { @@ -46,7 +45,6 @@ bool BehaviourTree::execute_next() { } if (this->current->get_parent() != next) { next->enter(); - next->execute(); } this->current = next; return cast_to(this->current) || this->current->get_status() == BehaviourNode::Fail;