You can use Linear/Linear Coupler mates in SOLIDWORKS Motion. (You can add the mates without having SOLIDWORKS Motion added in.) See SOLIDWORKS Help: Motion for Components Mated with Linear Couplers.
When you create a linear/linear coupler mate, you can set up the motion of each component with respect to ground or with respect to a reference component.
To add a linear/linear coupler mate: