I'm new in Unity, so I hope you guys can help. I'm developing a 2D-game for Android device, on the scene I have a huge background image inside Scroll View (UI - Scroll View).

Next, I created new empty Game Object "Players", attached to it "Players script" and added "Sprite Renderer" component.

From the Sprites I created two prefabs - housePrefab and dogPrefab. Inside "Players script" I have the following code:

[SerializeField] GameObject housePrefab;
[SerializeField] GameObject dogPrefab;

void Start()
var houseXPos = 1.41f;
var houseYPos = 2.63f;

var dogXPos = -0.41f;
var dogYPos = 2.63f;

GameObject house = Instantiate(housePrefab, transform.position = new Vector2(houseXPos, houseYPos), Quaternion.identity) as GameObject;
GameObject dog = Instantiate(dogPrefab, transform.position = new Vector2(dogXPos, dogYPos), Quaternion.identity) as GameObject;

After I run game both Sprites appears on the screen (as I expected). The problem occurs when I Scroll background image, both sprites stay in the same position under scrolling. In other words sprites not scrolling with the background image.

As far as I understand, the Sprites needs to be added to the background image, but I don’t know how to do it. How to make Sprites scroll with the background image?

Thanks to all in advance.

  • \$\begingroup\$ Has been a long time, but virtouso's comments were right, though what I think you want to do is have a gameObject in the scene with spriterenderer for your background, have the same with the house and dog sprites, and make a script that allows you to move the camera by swiping, instead of using UI elements such as scrollview. Then all sprites should move away while your background moves... \$\endgroup\$
    – D.Kallan
    Feb 17, 2021 at 6:25

1 Answer 1


Your background is a UI canvas, but your playing objects are in the scene and not dependent. Your approach is wrong.

If you need a background for you game, just make a simple 2D object with SpriteRenderer and scale it to fill the camera view. Then make it child of the camera (drag in hierarchi and drop on camera).

Then you can define any behaviour for your characters.

  • \$\begingroup\$ virtouso, thank you for your answer. Here is what I did: 1. Created a new Scene 2. Hierarchy - 2D Object - Sprite 3. Inspector - Sprite Renderer - Sprite, selected my background image 4. In hierarchy I drop object that I created in step 2 on the camera 5. Pressed play. I see background image, but it’s not scrollable I definitely did something wrong, but I’m not sure what. \$\endgroup\$
    – dakath
    Aug 26, 2019 at 19:17
  • \$\begingroup\$ @dakath because that a UI. ui is over everything in game. you shouldnt use UI as background \$\endgroup\$
    – virtouso
    Aug 26, 2019 at 19:21
  • \$\begingroup\$ Ok, what should I use instead of UI? Could you please, explain in more detail? Or link me to some tuts? I googled how to make the scrollable background and most of the tuts say use UI - Scroll View \$\endgroup\$
    – dakath
    Aug 26, 2019 at 19:29
  • \$\begingroup\$ @dakath i just said in answer. a 2d object and scale to fill the background. and z value less than all objects in the scene \$\endgroup\$
    – virtouso
    Aug 26, 2019 at 19:31
  • \$\begingroup\$ I still not get how to do that, but it's ok, will try to find an answer by my self. Thank you again for your time and help. \$\endgroup\$
    – dakath
    Aug 26, 2019 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .