Right approach for long flat 2d background image

Hello all, I’m new to game development (came from iOS apps[obj-c/swift] development) and I’m trying to find the right way to add a long flat 2d background image.

I’ll explain: user can move all directions but only when he move right the background image will move left according to player movement.
What should move is the camera (to the right) or the background itself (to the left)?

What is the right approach to handle it?

It sounds like you’re talking about a parallax background. With some tweaks, I think this 1 will help you a lot.

Hope this helps! Good luck :slight_smile:

If you are using Perspective camera it will automatically create depth.You can gain parallax view without any codes.But If you are using an Orthographic camera to create a parallax view first change the Texture type of your image to texture

77057-screenshot-1.jpg

create a quad and drag and drop your Texture image into the quad and apply this code.

public float speed;


// Use this for initialization
void Start () 
{

}

// Update is called once per frame
void Update()
{

    Vector2 offset = new Vector2(Time.time * speed, 0);
    GetComponent<Renderer>().material.mainTextureOffset = offset;

    
}