feat: MoveTo state now uses Unit::movement_speed
This commit is contained in:
parent
cabaae949c
commit
e1ebee99e1
|
@ -12,10 +12,10 @@ void MoveTo::_ready() {
|
|||
if(this->target_node == nullptr) {
|
||||
this->end_state();
|
||||
gd::UtilityFunctions::push_warning("failed to start MoveTo state due to missing target");
|
||||
return;
|
||||
} else {
|
||||
this->agent->connect("velocity_computed", this->nav_velocity_computed);
|
||||
this->calculate_path();
|
||||
}
|
||||
this->agent->connect("velocity_computed", this->nav_velocity_computed);
|
||||
this->calculate_path();
|
||||
}
|
||||
|
||||
void MoveTo::_end_state() {
|
||||
|
@ -29,7 +29,7 @@ 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->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)
|
||||
this->end_state();
|
||||
|
@ -65,8 +65,7 @@ double MoveTo::get_repath_interval() const {
|
|||
if(target_delta_position == 0.f)
|
||||
return INFINITY;
|
||||
else
|
||||
return gd::Math::max(gd::Math::min(double(this->distance_to_target()), 5.0)
|
||||
- target_delta_position, 0.2);
|
||||
return gd::Math::max(gd::Math::min(double(this->distance_to_target()), 5.0) - target_delta_position, 0.2);
|
||||
}
|
||||
|
||||
void Activate::_bind_methods() {}
|
||||
|
|
Loading…
Reference in a new issue