Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by helios · Sep 08, 2011 at 03:35 AM · 2dorthographicparallax

Most efficient way to achieve 2D parallax effect with orthographic camera?

I am currently making a 2D game with an orthographic camera. I have different "layers" that I am trying to manually give parallax. I know the logic behind it is simple, but what is the most code-efficient way of achieving this? I'm thinking of some parallax script that I can just attach on each layer, but I would like it to run smoothly on mobile. Anyone have any suggestions? Thanks!

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

2 Replies

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

Answer by vxssmatty · Sep 08, 2011 at 03:44 AM

Click on your 'Parallax' tag... read the questions asked before with it and see if that helps you...

How i generally do it though;

Player or Enviroment has a movement/speed property - I choose one to be the 'Master'

Then i create a script that controls movement of the other object (texture offset, geometry, etc) and also control limits that i might want to impose, then i read the speed from the 'Master' and multiply that by a float (0.5) to get half the speed... substitute the float to change rate.

Your done :)

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 helios · Sep 11, 2011 at 07:49 PM 0
Share

Does your camera not move at all then? Is your camera stationary and you just scroll your elements?

avatar image sacredgeometry · Sep 11, 2011 at 08:32 PM 1
Share

I think he meant move the background scene items relative to the cameras position and the cameras position tracks to the players position. So in other words the foreground objects are normal but the background objects move in a negative relation with the camera with movement speeds decreasing depending on how far away they are supposed to be.

avatar image helios · Sep 11, 2011 at 09:22 PM 2
Share

But how can I simply track that? I can't just have my background layer equal, for example, to half of the cameras position. I feel like this is such a simple task, yet I have no idea why I'm struggling in getting it to work. I just have it so each layer has this script (psuedo-code) attached:

thisTransform.position.x = -mainCamera.transform.position.x * speedX; thisTransform.position.y = -mainCamera.transform.position.y * speedY;

Should this be working?

avatar image sacredgeometry · Sep 11, 2011 at 09:30 PM 0
Share

Yes that is basically how i did it, its a very simple way to do it, you can even grab the distance from camera to create an auto script for layers so anything you position will automatically have the right speed parallax relative to other assets positioned in z-space.

avatar image Salazar · Sep 27, 2014 at 10:40 AM 0
Share

This solution has a performance problem on mobile platform in my experience. I find a solution but it didnt give that effect.

I write a solution of my experience here.

avatar image
0

Answer by BASICSPACE · Jul 02, 2014 at 10:09 AM

Here's a script that will allow you to create parallax layers of transparent seamless textures in front or behind your scene. Its's designed especially for the orthographic camera. https://www.assetstore.unity3d.com/en/#!/content/18342

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Background Image as Orthographic 2D Game Background - and quick 2D parallaxing question 1 Answer

My parallaxing is moving by it self? 1 Answer

parallax scrolling using orthographic camera 1 Answer

Dynamic Orthagraphic Camera Zoom 1 Answer

2D Camera Question: Pixel Perfect W/O Cutting Bottom Edges 1 Answer


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