Testing out curves to create a bobbing motion after the node reaches it's target destination, but once the bobbing motion starts the position is reset to 0. I don't know how to stop this from happening. I have tried exchanging position.y for velocity and multiplying the position by direction, but while the current position is kept, the resulting motion looks like a hard bounce when reaching the lowest position. The code is pasted below. Is there an easier way to do this? Thanks in advance.
if global_position != target.global_position && startup == true:
var path_direction = target.global_position - global_position
time_elapsed += (delta/ travel_time)
position = position + path_direction * position_curve.sample(time_elapsed)
else:
startup = false
if startup == false:
time_elapsed += delta * dir
if time_elapsed >= 1:
dir = -dir
elif time_elapsed <= 0:
dir = -dir
position.y = position_curve.sample(time_elapsed) * travel_time```