I’m in the process of making a 2d side scroller similar in style to mario, and I’ve drawn up a simple background image to be used, and I was just wondering what the best way is to take it into unity
Right now I’m using a plane with my background image placed as a texture, but it seems rather nasty - as you stretch the game window you start to see blank spaces (as the plane is not big enough)
What do you want to happen at the edges, where the plane ends? Should the background repeat at that point?
If so, a good first step would probably be to double or triple the scale of the plane (in the appropriate dimensions), and then set the tiling for the texture accordingly. This will make your background cover more area and repeat a few times, which should address the problem you mentioned.
It that doesn’t suit your needs, perhaps you could describe the problem in a little more detail (e.g. whether you need the background to scroll indefinitely, etc.).
Well the background image I made in photoshop is very long in width and normal in height - so I dont want it to repeat, I just want the bg image to stay still while the camera scrolls through it
Hm, I guess I’m not clear on what the problem is. What do you mean by ‘stretch the game window’? Are you talking about increasing the aspect ratio? And if your plane isn’t big enough, can’t you just make it bigger?
i meant making the game window bigger by dragging one of the corners further to make the window bigger
Just think of it like in mario. As mario runs to the right of the screen, the background image stays in place physically, but the camera moves to the right and thus shows a different part of the background.
I suppose I could just make the plane the same size as the game window but in my head that seems like a very ugly solution and wouldnt work very well since people have different sized screens
I was under the impression that the Unity window wasn’t resizable. Is that a Unity 3 feature? Or are you just talking about resizing the game view in the editor?
actually you are right , I hadn’t tested it while it’s built, but yes if I resize the editor window it tends to screw up, but I suppose this is fine as this wont happen after it’s built
Aside from that, is there any other neat way of doing this without using a plane?
For this, you might want to have two cameras. One which is orthographic and will not distort the image in the background and draw it first, then draw the foreground however you want. If you want a pixel-perfect background, otherwise the edges may be distorted.