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
2
Question by Aurelio Provedo · Apr 14, 2011 at 07:03 AM · cameratransitionperspectiveortographic

Transition a camera from ortographic to perspective mode (Trombone effect)

I am fiddling with the idea of implementing smooth camera transitions from ortographic to perspective mode. I think this would make for a cool effect in my videogame.

I assume that the values involved in the interpolation would be 'ortographicSize' and 'fieldOfView'.

I plan on modifying those two variables in the Update method, by using Interp or SmoothDamp or any other similar function to smooth out the values.

But, how can I correspond ortographic mode's 'size' to perspective mode's 'fieldOfView'? Is there any actual relationship between them that can be calculated?

I notice that decreasing the fieldOfView actually makes the perspective camera become more and more ortographic, while at the same time zooming in. But I don't want it to zoom in, I just want things to appear gradually flatter.

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 DaveA · Apr 14, 2011 at 07:38 AM

What you really want is the 'trombone effect'. Use a perspective camera, but 'fake' the ortho view by using a very small fieldOfView and set a long distance away. Then interpolate over time the fieldOfView to something normal like 60 and closer distance (or vice versa for reverse effect).

It goes something like this (my code is more complex so I'm just snipping the math out here.

Update: tmin = targetGameObject.renderer.bounds.min; tmax = targetGameObject.renderer.bounds.max;

// we would like to keep tmin and tmax constant c = (tmax.x - tmin.x) / 2;

if (Camera.main.transform.position.z > .0001 || Camera.main.transform.position.z < -.0001) Camera.main.fov = Mathf.Abs(4*180.0 / 3.14159 * Mathf.Atan(c/Camera.main.transform.position.z)); if (Camera.main.fov < 0.01) Camera.main.fov = 0.01; if (Camera.main.fov > 180.0) Camera.main.fov = 180.0;

Comment
Add comment · Show 6 · 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 Aurelio Provedo · Apr 14, 2011 at 07:46 AM 0
Share

I know, and thanks for answering BTW, but I still don't know how to match a certain 'fieldOfView' with how much zoom out I should do to compensate. I don't want the camera to zoom in or out when changing the fieldOfView.

avatar image Jean-Fabre · Apr 14, 2011 at 07:57 AM 0
Share

You'll need to computer the camera view unit in world unit and modify the field of view as you animate the camera position so that the view unit/world unit ratio stays the same.

avatar image Aurelio Provedo · Apr 14, 2011 at 09:38 AM 0
Share

That is great, $$anonymous$$ Fabre. Thank you. But how can I calculate that? What are the variables for finding that ratio? $$anonymous$$aybe I could get the camera's 'cameraToWorld$$anonymous$$atrix' and then use $$anonymous$$ultiplyPoint() to get the world extents of the camera... I think I'm going to spend a good while studying math about projection matrices right now ;-) Oh, and post an answer ins$$anonymous$$d of a comment, so I can upvote you.

avatar image DaveA · Apr 14, 2011 at 05:11 PM 0
Share

Posted code, above

avatar image Aurelio Provedo · Apr 15, 2011 at 06:39 AM 0
Share

What is variable 'd' for?

Show more comments
avatar image
1

Answer by anomalous_underdog · May 16, 2011 at 06:13 AM

I found this code at the forums and it works like a charm: http://forum.unity3d.com/threads/32765-Smooth-transition-between-perspective-and-orthographic-modes

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

No one has followed this question yet.

Related Questions

Help with ortographic camera 1 Answer

Unity3d or Maya-style Camera navigation 5 Answers

Direct positioning with a perspective camera? 2 Answers

Click and Drag Camera only works in Orthographic camera 1 Answer

Help Please - 2D Game Perspective Camera 2 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