Make animation not depending on position

My script makes a object move up and down and play an animation that slowly moves the object a little bit up, and then a little bit down.
t

But when i move the object up and release the key the object moves back down to where the animation is recorded. How can i make it so it does not depend on the position and it can play everywhere?

Put your object in a parent gameobject, so the animation is relative to that parent.
Then just move the parent.