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