x


2D Parallax Background

I would like to made a 2D scrolling game (up,down,left,right) which uses parallax with its background. So the player would appear to move slowly across of it. Any pointers on how to go about accomplishing this task?

more ▼

asked Dec 13 '10 at 04:10 PM

spaceshooter gravatar image

spaceshooter
249 49 55 69

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Multiple "planes" (at least the front of which with transparency) at different depths, "moving" at different speeds relative to the camera.

You "planes" could be planes or cylinders or spheres as you like.

"Moving" your background is up to your discretion. If using tiled textures, then you would simply change the offset. If using the actual geo, you would move them at different speeds.

An alternative setup is to have a second camera render your different depth to a RenderTexture, but that is Pro-only and somewhat overkill.

more ▼

answered Dec 13 '10 at 04:17 PM

skovacs1 gravatar image

skovacs1
10k 11 25 91

Haha, you're the one that posted on the link I posted =).

Dec 13 '10 at 04:19 PM Justin Warner

I am, but that question was looking for a custom camera rotational control, hence why I provided a different and much simpler answer here.

Dec 13 '10 at 04:21 PM skovacs1

Without the pro version, you can also use multiple cameras to achieve a parallax effect, and it's actually as easy - or maybe easier - than the method described above.

All you have to do for this to work is to assign your scene objects to different custom layers (e.g. Foreground, Background1 and Background2). Next, you'll have to set the 'Depth' value of your cameras, so they are rendered in the correct order (back to front) and 'Clear Flags' needs to be set to 'Depth only' for all cameras except the one rendering the farthest background. Then, the only code required is to move the background cameras at a slower speed than the foreground camera.

Oct 20 '11 at 08:17 AM bernardfrancois
(comments are locked)
10|3000 characters needed characters left

http://answers.unity3d.com/questions/21795/how-to-copy-camera-rotation-plus-custom-setup-for-parallax-scrolling

Enjoy =).

I'd personally make a cylinder big enough, apply the background, and just have the cylinder to rotate, but then again, that'd be a horrible way of doing it, haha.

more ▼

answered Dec 13 '10 at 04:16 PM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

I think this is a lot more complicated than what I need, thanks though. I'm sure it will come in handy sometime.

Dec 13 '10 at 04:55 PM spaceshooter
(comments are locked)
10|3000 characters needed characters left

Some great answers here. I'm gonna try adding 3 planes, one behind the other and just adjust the speed of them scrolling depending on their position relative to the camera. Closest scrolls fastest, etc... Thanks for the tips guys and gals!

more ▼

answered Apr 30 '12 at 11:50 PM

NorthernEagle gravatar image

NorthernEagle
71 6 11 12

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x166
x56
x24

asked: Dec 13 '10 at 04:10 PM

Seen: 10064 times

Last Updated: Apr 30 '12 at 11:50 PM