# Help with 2D parallax not based on camera

Hello everyone,
I’m learning Unity by making a feature-rich Flappy Bird. I wish to have a parallax scrolling background.
I’ve made the base flappy bird. The bird is still, and can only jump in the Y axis. The pipes are spawned
on the right side of the screen, and more towards the left, where they get despawned.
I’ve followed Dani’s tutorial on parallax backgrounds, and it works. But it’s based on the camera moving.
How could I achieve a constantly scrolling parallax background without changing how I made the game?

I’ve tried to find a solution already made but to no avail.
I hope someone can help me out, or at least point me in the right direction.

Background code:

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Parallax : MonoBehaviour {

private float length, startpos;
public GameObject cam;
public float moveSpeed;
public float parallaxEffect;

// Start is called before the first frame update
void Start()
{
startpos = transform.position.x;
length = GetComponent<SpriteRenderer>().bounds.size.x;
}

// Update is called once per frame
void Update()
{
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
float temp = (transform.position.x  * (1-parallaxEffect));
float dist = (transform.position.x * parallaxEffect);

transform.position = new Vector3(startpos + dist, transform.position.y, transform.position.z);
if(temp > startpos + length) startpos += length;
else if (temp < startpos - length) startpos -= length;
}
}
``````

Simply move layers that are further back a little slower.

Since what you’re doing is faux parallax, it is not mathematically defined how much slower, so you can play with it and see.

Moving it at half the speed will give a sensation that it is approximately twice as far away as the foreplane.