How create a Scrolling Background with Parallax Effect in Unity

Here are the steps to create a scrolling background in Unity.

1. Add background to Scene
2. Duplicate (I did it twice and flipped the middle background on the X)
3. Set the new ones as childs of the 1st one
4. Align the backgrounds
5. Move the parent background (Y:-80)
6. Add the script

Infinite Scrolling Code

[SerializeField] private float _scrollSpeed = -5f;
private Vector2 _startPos;

// Start is called before the first frame update
void Start()
{
_startPos = transform.position;
}

// Update is called once per frame
void Update()
{
float newPos = Mathf.Repeat(Time.time * _scrollSpeed, 80);
transform.position = _startPos + Vector2.up * newPos;
}

Parallax Effect

4 layers scrolling backgrounds

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.