Background Looping
While asteroids move toward spaceship, if we add a looping effect on background, it will create a visual effect of spaceship moving forward in an environment. To do this following steps were taken:
MoveObject.cs script was attached to the background,
LoopBackground.cs script is created and attached to background
In the LoopBackground script:
starting position of the background was stored in a variable startPos (in Start() method)
repeat width is set to be half of the z size of the background
Condition: if the position.z of the background is less than the repeat width, then the position of background is set to startPos.
A box collider was added to the background image. This box collider covers the entire image. And, the collider contains the Size property that will provide us the size of the image.
Box Collider Caption