Moving Background with translated images

Hello, I have been having some trouble making a moving background that consists of images that represent waves.

What I want to do is have 2 images: Wave1 and Wave2.

I want to move them from right to left continously, by moving them and changing their position once they get off camera.

So it looks like Wave1 Wave2 (changeWave1 position) Wave1 Wave2 Wave1 Wave2 Wave1

I hope that is clear.

Anyway, All I do is move them with Lerp, and check their position relative to the Camera, if they get out of view, I change their positions from the left of the camera to the right of the camera, so they appear again on the right side of the camera. (exit on left, change position, appear on right).

That works well, the problem is when I move the camera (it follows a player), the script constantly checks if the wave is off camera, and moves it on camera again (relative to the cameras position of course), and SOME TIMES the position is not set right, and a little space appears between the wave images…

I need to fix this, is there a simpler way of doing what I’m doing? is that little white space due to the time it takes my computer to run the code?

Please help, I hope I made myself clear enough, as english is not my native language.

Say your wave object is SIZE units in size.

if ( wave.transform.position.x < minimumX ) {
  wave.transform.position.x += SIZE;
}

This will force your object to “align with itself”; if it has a repeating image it should line up properly. This is because you’re setting it relative to itself so you know it will match its own graphics.