From 75e73aba9503b0270f0e7543f2f2eaf7ea283c8e Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 9 Aug 2024 17:57:42 +0200 Subject: [PATCH] fix: MoveTo now avoids setting velocity after calling end_state --- src/rts_states.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rts_states.cpp b/src/rts_states.cpp index e6fd875..2987385 100644 --- a/src/rts_states.cpp +++ b/src/rts_states.cpp @@ -29,10 +29,12 @@ void MoveTo::_process(double) { gd::Vector3 const pos = this->parent_unit->get_global_position(); gd::Vector3 const target = this->agent->get_next_path_position(); gd::Vector3 const direction = (target - pos).normalized(); - this->agent->set_velocity(direction * this->parent_unit->get_movement_speed()); bool const navigation_finished{this->agent->is_navigation_finished()}; - if(this->is_action_done_interrupt() || navigation_finished) + if(this->is_action_done_interrupt() || navigation_finished) { this->end_state(); + return; + } + this->agent->set_velocity(direction * this->parent_unit->get_movement_speed()); if((utils::time_seconds() - this->last_repath) > this->get_repath_interval()) this->calculate_path(); }