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 Jonesy19 · Dec 22, 2016 at 04:47 PM · unity 2daxisorthographicperspectiveparallax

Perspective Camera on only one axis.

Hi everyone, I'm creating a 2D game with a parallax background. I am using a perspective camera to do this. I'm looking for an effect where ONLY the X-axis is effected by the perspective camera, and the Y-Axis is not.

I know this can be done with an orthographic camera and scripts that manually move the objects, but it just makes things simpler to use a perspective camera. Anyways, is there a way to make a perspective camera perspective on the X-Axis and orthographic on the Y-Axis?

Thanks for the help!

Comment
Add comment · Show 9
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 destructivArts · Dec 22, 2016 at 08:15 PM 0
Share

Can you describe what you mean in more detail? ie. If I use the camera you are describing to render a cube, what does it look like, if I put the cube on the left edge of the screen? On the right? At the top? etc.

avatar image Jonesy19 destructivArts · Dec 22, 2016 at 08:19 PM 0
Share

Sure, sorry - I probably could have been more descriptive...

I have say 100 sprites in my scene (it's a Unity2D game). I have 5 layers, one main layer that pans with the camera (no parallax), 3 layers behind the main layer (these layers progressively go slower as they get further back), and one layer in front of the main layer, which moves faster than the main layer. Now, I want all the parallax effects that I am describing to happen when the camera moves left to right. What I don't want to happen, is any parallax effect to happen when the camera moves up and down. I want all of the layers to move up and down the same exact difference....

Does that make more sense? I know I can create a script that does this, using an orthographic camera. 1) I am not sure of the performace hit this will take. 2) that seems like a more complicated approach.

Anyways, thanks for the help!

avatar image destructivArts Jonesy19 · Dec 22, 2016 at 08:38 PM 0
Share

What is the reason you want to use a perspective camera? I'd honestly do this with an orthographic camera, unless there's some effect you really want to have be in perspective.

All you'd have to do to get parallaxing with a perspective camera is move the layers backward or forward in space. The perspectival nature of the camera will take care of the rest. Unfortunately, this comes with the added effect of working both horizontally and vertically. You could probably write some script to account for, and negate the visual effects of vertical camera movement, but this seems like an overly complex solution to your problem ( something along the lines of this ).

However, the solution when using an orthographic camera is simply:

 void Update () {
     transform.Translate ( cameraPositionChange.x * layerNumber, 0, 0 );
 }

avatar image Jonesy19 destructivArts · Dec 22, 2016 at 08:33 PM 0
Share

I actually just tested it and the orthographic scripts seem to hurt performance greatly, dropping FPS from 60 to nearly 30 when I move the camera. If I use a plain old perspective camera, the performance is hardly dropped when the camera moves.

avatar image destructivArts Jonesy19 · Dec 22, 2016 at 08:39 PM 0
Share

Can you post the script you're using? This doesn't seem like something that should be performance intensive.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jonesy19 · Dec 29, 2016 at 04:00 PM

Thanks for the help guys. I appreciate it!

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

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

62 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is my parallax effect glitching out with my perspective camera? 1 Answer

Vertical Perspective / Horizontal Orthographic 1 Answer

Can I make a camera that has an orthographic vertical axis, but a perspective on the horzontal axis? 1 Answer

Draw orthographic visuals (e.g. health bar) in perspective scene? 4 Answers

Rendering a 3D object within a specific area/bound? 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