From 0eb4adc48c2e62ab61ceb709371a6d7ccd7e2123 Mon Sep 17 00:00:00 2001 From: Francois Belair Date: Tue, 21 Jan 2020 12:49:46 -0500 Subject: [PATCH] Fix bug for collision avoid direction reversed Once the agent was close enough to a neighbor, it tried to get closer instead of away. --- project/src/Behaviors/GSTAvoidCollisions.gd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/src/Behaviors/GSTAvoidCollisions.gd b/project/src/Behaviors/GSTAvoidCollisions.gd index 8fd9089..046dd71 100644 --- a/project/src/Behaviors/GSTAvoidCollisions.gd +++ b/project/src/Behaviors/GSTAvoidCollisions.gd @@ -32,8 +32,9 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAccele acceleration.linear = first_neighbor.position - agent.position else: acceleration.linear = first_relative_position + (first_relative_velocity * shortest_time) - acceleration.linear = acceleration.linear.normalized() * -agent.max_linear_acceleration - acceleration.angular = 0 + + acceleration.linear = acceleration.linear.normalized() * -agent.max_linear_acceleration + acceleration.angular = 0 return acceleration