Fix velocity reversal bug in kinematic agents

Fixes #40
This commit is contained in:
Francois Belair 2020-03-19 23:32:08 -04:00
parent beca7b9cc7
commit 89e4dc4c2b
3 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,10 @@ This document lists new features, improvements, changes, and bug fixes in every
- Acceleration for agents are now multiplied by delta in order to make acceleration be per second instead of instant. The demos' values have been increased significantly to better fit with reality.
### Fixes
- KinematicBody2DAgents and KinematicBody3DAgents that moved fast enough no longer reverse velocity suddenly during a frame where no acceleration is applied.
## Godot Steering AI Framework 2.1.0 ##
### Features ###

View File

@ -128,7 +128,7 @@ func _on_SceneTree_physics_frame() -> void:
_applied_steering = false
else:
linear_velocity = GSAIUtils.clampedv3(
GSAIUtils.to_vector3(_last_position - current_position), linear_speed_max
GSAIUtils.to_vector3(current_position - _last_position), linear_speed_max
)
if apply_linear_drag:
linear_velocity = linear_velocity.linear_interpolate(

View File

@ -128,7 +128,7 @@ func _on_SceneTree_physics_frame() -> void:
_applied_steering = false
else:
linear_velocity = GSAIUtils.clampedv3(
_last_position - current_position, linear_speed_max
current_position - _last_position, linear_speed_max
)
if apply_linear_drag:
linear_velocity = linear_velocity.linear_interpolate(