• 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 Eowyn27 · Jan 07, 2014 at 04:41 PM · camera movementorthographicmaincamera

How do I adjust size of orthographic camera when moving the camera to a new view?

Spend some time thinking about why my view appears too zoomed in and chopped off when my camera moves from one object to another. I realized that it has to do with my main camera's settings before moving the camera to another object.

My main camera is orthographic and the size is very small (1.3) so that I can view all of my complex object. When I click on a part of my complex object, the camera moves to a new view that's far away to another object those scale is different than my complex object.

This view appears too zoomed and/or chopped off when I adjust the Z axis to try and fix it. However, it seems to be because of the size of my orthographic camera is set to 1.3 when it should be higher number for a normal view.

Now, I am just wondering how do I change the size of my main camera when my camera's view changes to another object on mouse down?

Here's the camera moving script:

 using UnityEngine;
 using System.Collections;

 public class MoveCamToObject : MonoBehaviour {

 public Camera mainCam;
  
 void OnMouseUp() {

  mainCam.transform.position = new Vector3(-33, 241, 362); // These values I adjusted to an orthographic camera with size 90. 
  
    
 }
 

}

I'm looking for a way to change the size in C#.

Comment
Add comment · Show 1
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 sath · Jan 07, 2014 at 06:14 PM 0
Share

a wonderful explanation by @duck

http://answers.unity3d.com/questions/15252/zoom-out-in-orthographic-view.html

http://docs.unity3d.com/Documentation/ScriptReference/Camera-orthographicSize.html

1 Reply

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

Answer by Eowyn27 · Jan 07, 2014 at 06:19 PM

Hi,

I figured it out and I decided to post the solution so that it can help others too:

 Camera.main.orthographicSize = 100; 

I put that script after my transform.position script.

Curious to see how other answers differ though (Perhaps, a non hard coded solution?)

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 alarm656 · Aug 15, 2017 at 10:01 PM 0
Share

It's jumps from default size to size that you put. How to change it smoothly?

avatar image Fragmental alarm656 · Aug 16, 2018 at 04:38 AM 0
Share

https://forum.unity.com/threads/smooth-transition-between-perspective-and-orthographic-modes.32765/ here is a solution. You'll have to use "GetComponent()" ins$$anonymous$$d of "camera" because the latter was deprecated.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

How do I keep an Ortho camera in a specific range when the ortho changes? 3 Answers

Is smooth movement possible in Unity with a fixed camera? 3 Answers

Orthographic camera size question 1 Answer

Detect if a GameObject is partially behind another? 1 Answer

is it possible to set the view port rect at both ends 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