Fix bug with implementation of drag in Arrive

Drag should inexorably draw towards 0, but when slow enough it could
instead cause a reverse direction.
This commit is contained in:
Francois Belair 2020-01-15 10:44:21 -05:00
parent fa91e6bca7
commit 617b837772

View File

@ -36,7 +36,7 @@ func _unhandled_input(event: InputEvent) -> void:
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
_accel = _arrive.calculate_steering(_accel) _accel = _arrive.calculate_steering(_accel)
_velocity += Vector2(_accel.linear.x, _accel.linear.y) _velocity += Vector2(_accel.linear.x, _accel.linear.y)
_velocity -= _velocity * _drag * delta _velocity = _velocity.linear_interpolate(Vector2.ZERO, 0.1)
_velocity = move_and_slide(_velocity) _velocity = move_and_slide(_velocity)
_update_agent() _update_agent()