• 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 raggi · Apr 16, 2010 at 11:15 AM · 2dzoomorthographicside-scrolling

Zoom out in orthographic view?

hey guys, im working on a 2d side scroller based on the 2d tutorial. im working with 2d assets and using sprite manager to deal with the animation. I want to use the zoom features that is set up in the tutorial. it sets the camera distance on certain positions, but when I switch the view to orthographic the distance gets replaced with orthographic size...

so my question is this. dose anyone know what I should change in the code to get the camera to zoom out in orthographic mode?

ive tried to change the camera distance part to orthographic size but it was not it, at least not just that.

the reason for using orthographic view is that Im running into trouble with the assets that are in front and in the back, they are jumping around the z axis, it seems to be something unity dose to give a more realistic sense of depth.

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
9

Answer by duck · Apr 16, 2010 at 11:35 AM

The orthographicSize property of your camera actually is the correct value to change in order to zoom in and out when your camera is in orthographic mode.

Changing the orthographic size of your camera shouldn't affect anything else in your scene - i.e. it shouldn't cause anything to "jump around on the z axis", it should simple crop or expand your view to show a smaller or larger area.

This is very different from actually moving your camera closer or further from your object. You don't need to actually move the camera at all while you're doing this.

If this doesn't solve your problem, you might have to describe more clearly the problems that you're having with things "jumping around".

Comment
Add comment · Show 4 · 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 raggi · Apr 16, 2010 at 11:39 AM 0
Share

thanks for the you comment, ive gotten it to work now but the thing is, its jumping from one "zoom" to the other, is there a way to make it smooth, like when your moving the camera in closer ?

avatar image spinaljack · Apr 16, 2010 at 12:10 PM 0
Share

$$anonymous$$ake the change in orthographic size more gradual, it doesn't need to be whole numbers. Also you can multiply the change by deltatime to make the zoom relative to real time rather than number of cycles.

avatar image bernardfrancois · Oct 10, 2011 at 10:16 AM 1
Share

One think you could to to implement a smooth orthographic camera size zoom is by using code similar to this:

zoomTimePassed += Time.deltaTime;

float t = zoomTimePassed / TOTAL_ZOO$$anonymous$$_TI$$anonymous$$E;

camera.main.orthograhicSize = $$anonymous$$athf.SmoothStep(initialZoom, newZoom, t);

Note that I haven't tested this code, but it should convey the idea of how it could be done.

The SmoothStep function will smoothly change the zoom, without any abrupt changes in the speed at which the zoom is changed.

avatar image emmalloyd · Jun 09, 2014 at 02:01 PM 0
Share

I know this is an old post but thank you! I was having trouble with this also. I had worked out that $$anonymous$$athf.smoothStep was needed, but I couldn't get it to work nicely. This code snippet worked perfectly for me! :)

avatar image
0

Answer by allesisda · Apr 25, 2012 at 08:16 PM

i have a problem with zooming in orthografic view:

i build my HUD with gameobjects, and if i change dthe orthographic size i get super small/big HUD elements...

is there a simple way to scale them together with the O-size?

Comment
Add comment · Show 2 · 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 apocriva · Apr 26, 2012 at 06:49 PM 0
Share

You'll likely have to have your game area and HUD rendered using two separate cameras.

avatar image sotirosn · Nov 15, 2013 at 12:14 AM 0
Share

try orthographicSize = Screen.height/2;

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

Faking orthographic zoom by scaling positions 1 Answer

Dynamic Orthagraphic Camera Zoom 1 Answer

2D camera zoom in comparison to the height of target 2 Answers

parallax scrolling using orthographic camera 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges