We will keep going with the same game scene we left at the end of the previous recipe, so just stick with the instructions!
In the Scripts folder of your Project panel create a new C# script and name it
Back_Manager
.Double-click on the script to open it in Monodevelop.
Let's begin by creating the required variables: we need one public Transform variable to store the reference to the prefab to be used as the background panels and a few private vars to define things like the scale of the panels, the distance from the character, and a reference to the game character.
From a game logic perspective, the most important variable we are adding to the script is an
Array[]
variable type that we use to manage the three panels that repeat endlessly in the background. To achieve that, add the following lines at the beginning of the script:public Transform backBrick; private Transform[] backArray=new Transform[3]; private Transform thisChar; private float distance...