Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by spaceshooter · Dec 13, 2010 at 04:10 PM · backgroundscrollingparallax

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by skovacs1 · Dec 13, 2010 at 04:17 PM

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.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Justin Warner · Dec 13, 2010 at 04:19 PM 1
Share

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

avatar image skovacs1 · Dec 13, 2010 at 04:21 PM 1
Share

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

avatar image bernardfrancois · Oct 20, 2011 at 08:17 AM 3
Share

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.

avatar image M_Plot · Jul 03, 2013 at 09:25 AM 0
Share

Hey Bernard! Is this solution ressource hungry ? Would it run smoothly on a mobile device ?

avatar image bernardfrancois · Jul 03, 2013 at 11:31 AM 0
Share

@$$anonymous$$_Plot: It's definitely possible on mobile, and also does have an impact on the performance (probably increasing the amount of draw calls), but whether this is an issue depends on the other performance heavy things you may be doing.

Compared to rendering to a render texture, it would be faster (or at least as fast), and in terms of memory usage, it would be definitely better.

avatar image
3

Answer by Justin Warner · Dec 13, 2010 at 04:16 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image spaceshooter · Dec 13, 2010 at 04:55 PM 1
Share

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

avatar image
0

Answer by NorthernEagle · Apr 30, 2012 at 11:50 PM

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by BASICSPACE · Jul 03, 2014 at 02:38 PM

Try using seamless repeatable textures for backgrounds and foregrounds and render them on a quad scaled to the camera's vieport. This technique is very lightweight and easy to set up. This one might be usefull: http://vimeo.com/98545927

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Josh Naylor ♦♦ · Jul 03, 2014 at 02:39 PM 0
Share

nice necropost

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

parallax scrolling background 2 Answers

Parallax scrolling background performance problem 4 Answers

Moving Background with translated images 1 Answer

trouble with getting the background to show past the midground in 2d parallax backgrounds 0 Answers

How to create an infinite scrolling background in top down multi-directional shooters. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges