fix: MoveTo now avoids setting velocity after calling end_state

This commit is contained in:
Sara 2024-08-09 17:57:42 +02:00
parent cd94bb164e
commit 75e73aba95

View file

@ -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();
}