Had this problem myself a while back!
The way I solved it was by using an expression.
First key frame all your movements. So you'll need the start, end and the start again. Then hold down alt and click your position stopwatch, this will then open up an expression box which will say 'transform.position'. The expression I used for mine was
Watch it back and see how it works, but this is what I did and it worked for me
Be careful not to hold down control when doing this as you will delete the keyframes you made!!
For more complex work with expressions there are loads of help and tutorials out there, but I used a very simple one.
Hope this helps!
Sorry, just to clarify, you need to delete the text transform.position from the expression dialogue box, and then write in or copy in the one I used which is
Hope this helps and do check out and learn more about expressions, they're pretty handy to know about!
Just writing loopOut() sets the loop option to cycle which is not what you want. To thange the behavior to back and forth write:
Strangely enough if you go to Help>Expression Language and search for loop you'll find a complete listing of the loop functions and links to additional functions.
(default) Repeats the specified segment.
Repeats the specified segment, alternating between forward and backward.
Repeats the specified segment, but offsets each cycle by the difference in the value of the property at the start and end of the segment, multiplied by the number of times the segment has looped.
Does not repeat the specified segment, but continues to animate a property based on the velocity at the first or last keyframe. For example, if the last keyframe of a Scale property of a layer is 100%, the layer continues to scale from 100% to the Out point, instead of looping directly back to the Out point. This type does not accept akeyframes or duration argument.
Just another FYI to throw in the back of your memory, loopOut("cycle") needs 3 keyframes to create a seamless loop, first keyframe, second keyframe, then a copy of the first keyframe one frame later. If your animation needs to pingpong instead of cycle you only need 2.