diff --git a/CHANGELOG.md b/CHANGELOG.md index ba651e8..af5961b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### diff --git a/project/src/Agents/GSAIKinematicBody2DAgent.gd b/project/src/Agents/GSAIKinematicBody2DAgent.gd index 171e110..d8cfc45 100644 --- a/project/src/Agents/GSAIKinematicBody2DAgent.gd +++ b/project/src/Agents/GSAIKinematicBody2DAgent.gd @@ -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( diff --git a/project/src/Agents/GSAIKinematicBody3DAgent.gd b/project/src/Agents/GSAIKinematicBody3DAgent.gd index 62b3658..b5d3665 100644 --- a/project/src/Agents/GSAIKinematicBody3DAgent.gd +++ b/project/src/Agents/GSAIKinematicBody3DAgent.gd @@ -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(