Restart moving game object position

Hello all,

Currently, I’m working on a 2D side scroller (in C#). I have several objects in the background that move from left to right on the screen. Once the objects are out of viewport, I’d like for the objects to reset to a position on the left side of the viewport and start moving left to right again. Move the objects isn’t a problem. Just not sure the best way to go about resetting objects so that they start their journey again. What would be the best way to approach this?

Thanks in advance!

I haven’t used this yet, but try out the OnBecameInvisible() method. Something like this:

void OnBecameInvisible()
{
   // Position change
}

See here for more info: Unity - Scripting API: MonoBehaviour.OnBecameInvisible()