fix: WretchedPatrolState now works without a path
This commit is contained in:
parent
ec6fc76335
commit
d8aafba90e
4 changed files with 42 additions and 33 deletions
|
|
@ -56,17 +56,21 @@ void WretchedPatrolState::enter_state() {
|
|||
float const max_speed{ get_unit()->get_patrol_speed() };
|
||||
get_target()->set_movement_speed(max_speed);
|
||||
get_nav()->set_max_speed(max_speed);
|
||||
Vector3 const nav_target{ this->path->get_closest_point(get_target()->get_global_position(), &this->path_point) };
|
||||
set_patrol_target(nav_target);
|
||||
if (this->path) {
|
||||
Vector3 const nav_target{ this->path->get_closest_point(get_target()->get_global_position(), &this->path_point) };
|
||||
set_patrol_target(nav_target);
|
||||
}
|
||||
}
|
||||
|
||||
void WretchedPatrolState::process(double delta) {
|
||||
if (get_nav()->is_navigation_finished()) {
|
||||
this->path_point += 1;
|
||||
set_patrol_target(this->path->point_at(this->path_point));
|
||||
if (this->path) {
|
||||
if (get_nav()->is_navigation_finished()) {
|
||||
this->path_point += 1;
|
||||
set_patrol_target(this->path->point_at(this->path_point));
|
||||
}
|
||||
Vector3 const direction{ get_target()->get_global_position().direction_to(get_nav()->get_next_path_position()) };
|
||||
get_target()->set_movement_direction(Vector2{ direction.x, direction.z }.normalized());
|
||||
}
|
||||
Vector3 const direction{ get_target()->get_global_position().direction_to(get_nav()->get_next_path_position()) };
|
||||
get_target()->set_movement_direction(Vector2{ direction.x, direction.z }.normalized());
|
||||
}
|
||||
|
||||
String WretchedPatrolState::get_next_state() const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue