To start with, we will need a C# script.
Perform the following steps:
First, search the
Assets/Scripts
folder and right-click on it.Then, click on Create and select C# Script.
Now, name this
SceneBackground
.Finally, double-click on the
SceneBackground
file to open it.
The SceneBackground
file will hold four sprites. Each of these sprites will have their own movement speed and movement distance (speed being how fast they move and distance is how far forward and backward they can move).
Add the following code to the SceneBackground
file before the Start
function:
// Struct to hold data for Background Element [System.Serializable] public struct BackgroundElement { public Sprite BackgroundSprite; public float MovementSpeed; public float MovementDistance; public Vector3 SpriteLocation; public Vector3 SpriteScale; [System.NonSerialized] public Vector3 ObjectStartLocation; [System.NonSerialized] public...