I have a rigidbody2d character that has no gravity and no drag. I made a quick demonstration in the video to show the target goal of what it should look like, but basically the rigidbody2d is supposed to move up and down with easing, while being constrained to a range, imagine an idle animation.
So here's my current code:
func _idling(_delta) -> void:
if global_position.y < (y_anchor - y_anchor_distance):
idle_target = 1
elif global_position.y > (y_anchor + y_anchor_distance):
idle_target = -1
apply_central_force(Vector2(0, idle_strength * idle_target))```
The problem with this code is that its inconsistent. It goes up normally, but then shoots down and goes off track completely. I know i need to involve some kind of smoothing, but i cant figure something out with lerp()