Making a cube move along an infinity path in loop

I think you are looking for cinematics and motion paths.