Endless scene in Unity

In Unity sometimes we want to move our characters in a endless background, such as Runner or Flappy Bird. Such game required infinite loop of scene.

One of the solutions comes to mind is moving the camera along with the background. To achieve this is quite simple, the whole idea is to attach the background to your main camera:. The following example shows you how to do this:

A project with the following game objects, and put Plane under the main camera.

For the main camera, create a script named CameraFollow with the below code

CameraFollow C# Script
[gist https://gist.github.com/arkilis/2cc95d76d8f7ee994f44c6ab20875a53/]

Code: https://github.com/arkilis/EndlessInUnity/

About: arkilis

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.