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
0
Question by TokyoDan · Apr 11, 2013 at 06:01 AM · zoomlocalscaleorthographic camera

What is the best way to zoom a map with an orthographic camera?

This is similar to my previous question in that the game environment is the same: I'm making a 2D board game, the game board is situated such that The Main (orthographic) Camera looks down in the Y axis to see the face of the board. So looking at the board the x axis is left/right (west/east) and the z axis is top/bottom (north/south). The y axis is not used except to initially set the height (distance) of the camera from the board and should never be changed.

The game board is like a large map in that it is bigger than the orthographic camera's size so in order to see the whole map I have to either change the size of the orthographic camera OR scale the board ('GameBoardObj' in the example below).

What is the best way to implement this? (I'm using pinch gestures to zoom in/out of the map.)

  1. Adjusting the camera's view via Camera.orthographicSize

  2. Adjusting the map's scale via GameBoardObj.transform.localScale

  3. Other

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
2

Answer by whydoidoit · Apr 11, 2013 at 06:04 AM

I'd be using the orthographicSize - I wouldn't mess with your game objects scale (because it can cause problems with collision detection etc if things have colliders and don't have rigidbodies).

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 Fattie · Apr 11, 2013 at 06:08 AM 0
Share

it might be worth bearing in $$anonymous$$d that, very often with 2D type games, you'll be using multiple cameras. when you change the size, it will surely screw up other stuff (perhaps any UI, or if you're using 2DT$$anonymous$$ or the like)

so it may well be you have to use another or more cameras, when you do the zoom. ie anything that goes to hell because of the zoom, you'll need to go to a spearate camera for that maybe?

avatar image
2

Answer by fafase · Apr 11, 2013 at 06:13 AM

This is what we use for one of our game to Zoom in and out:

 if(GUI.RepeatButton (plusButton,"+")){
    if(camera.orthographicSize>= minPos)
       camera.orthographicSize -= Time.deltaTime * speedZoom;
 }
 if(GUI.RepeatButton (minusButton,"-")){
    if(camera.orthographicSize <= maxPos)
       camera.orthographicSize += Time.deltaTime * speedZoom;
 }

(plusButton and minusButton are the Rect)

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

13 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

Related Questions

Orthographic camera zoom towards transform 1 Answer

Touch code for panning and zooming not working 1 Answer

Pixel Perfect Camera Component 128 ppu pixel is too zoomed in for builds 1 Answer

Zooming in and out with an orthographic camera, while the bottom edge is fixed. 0 Answers

Why is my orthographic camera not resizing according to resolution / aspect? 0 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