Fix GSAIAvoidCollisions;s logic.

This commit is contained in:
Relintai 2023-01-14 15:33:52 +01:00
parent 67368542ad
commit 642a590949
2 changed files with 3 additions and 3 deletions

View File

@ -22,6 +22,7 @@ void GSAIAvoidCollisions::_calculate_steering(Ref<GSAITargetAcceleration> accele
if (neighbor_count == 0 || !_first_neighbor.is_valid()) { if (neighbor_count == 0 || !_first_neighbor.is_valid()) {
acceleration->set_zero(); acceleration->set_zero();
linear = Vector3();
} else { } else {
if ((_first_minimum_separation <= 0 || _first_distance < agent->get_bounding_radius() + _first_neighbor->get_bounding_radius())) { if ((_first_minimum_separation <= 0 || _first_distance < agent->get_bounding_radius() + _first_neighbor->get_bounding_radius())) {
linear = _first_neighbor->get_position() - agent->get_position(); linear = _first_neighbor->get_position() - agent->get_position();

View File

@ -37,8 +37,7 @@ void GSAIPriority::_calculate_steering(Ref<GSAITargetAcceleration> accel) {
int size = _behaviors.size(); int size = _behaviors.size();
if (size > 0) { if (size > 0) {
for (int i = 0; i < size; ++i) { //i in range(size) for (int i = 0; i < size; ++i) {
Ref<GSAISteeringBehavior> behavior = _behaviors[i]; Ref<GSAISteeringBehavior> behavior = _behaviors[i];
ERR_CONTINUE(!behavior.is_valid()); ERR_CONTINUE(!behavior.is_valid());
@ -58,7 +57,7 @@ void GSAIPriority::_calculate_steering(Ref<GSAITargetAcceleration> accel) {
GSAIPriority::GSAIPriority() { GSAIPriority::GSAIPriority() {
zero_threshold = 0.0; zero_threshold = 0.0;
_last_selected_index = 0; _last_selected_index = -1;
} }
GSAIPriority::~GSAIPriority() { GSAIPriority::~GSAIPriority() {