diff --git a/modules/steering_ai/behaviors/gsai_avoid_collisions.cpp b/modules/steering_ai/behaviors/gsai_avoid_collisions.cpp index 7001d1ed2..0539357a9 100644 --- a/modules/steering_ai/behaviors/gsai_avoid_collisions.cpp +++ b/modules/steering_ai/behaviors/gsai_avoid_collisions.cpp @@ -22,6 +22,7 @@ void GSAIAvoidCollisions::_calculate_steering(Ref accele if (neighbor_count == 0 || !_first_neighbor.is_valid()) { acceleration->set_zero(); + linear = Vector3(); } else { if ((_first_minimum_separation <= 0 || _first_distance < agent->get_bounding_radius() + _first_neighbor->get_bounding_radius())) { linear = _first_neighbor->get_position() - agent->get_position(); diff --git a/modules/steering_ai/behaviors/gsai_priority.cpp b/modules/steering_ai/behaviors/gsai_priority.cpp index 3fd2c21f8..d69c5b63b 100644 --- a/modules/steering_ai/behaviors/gsai_priority.cpp +++ b/modules/steering_ai/behaviors/gsai_priority.cpp @@ -37,8 +37,7 @@ void GSAIPriority::_calculate_steering(Ref accel) { int size = _behaviors.size(); if (size > 0) { - for (int i = 0; i < size; ++i) { //i in range(size) - + for (int i = 0; i < size; ++i) { Ref behavior = _behaviors[i]; ERR_CONTINUE(!behavior.is_valid()); @@ -58,7 +57,7 @@ void GSAIPriority::_calculate_steering(Ref accel) { GSAIPriority::GSAIPriority() { zero_threshold = 0.0; - _last_selected_index = 0; + _last_selected_index = -1; } GSAIPriority::~GSAIPriority() {