Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Posthuman-Wizard · Dec 07, 2012 at 07:01 PM · cameratranslateviewportisometricorthographic

Center Object in Viewport

Greetings; I am confronted with a problem that I am unsure of how to solve. I have an orthographic camera with a Y transform of 260 overlooking the scene. It has a rotation of X 25 and Y 50; "zooming in and out" is handled by changing the camera's projection size. This gives the project an isometric effect; moving up and down and zooming in and out works perfectly. However, a feature I'd like to add is the ability to click on an object in the viewport and move the camera accordingly so that the object is centered in the viewport. Getting the position of the object in world space and comparing it to the camera's is seemingly out of the question due to how the camera is set up. I know that I can get the object's viewport as opposed to its world position, but I'm unsure of what to do with it as far as accomplishing my goal is concerned. Any advice would be greatly appreciated.

Edit: I need the camera to slowly move to the target as opposed to snapping to it.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Philipp · Dec 10, 2012 at 05:37 PM

Your camera's transform has a Vector3 named forward. The camera position you want is the target position, plus this forward vector, times a scalar chosen so that the result is at y=260. In code: camPos = target.transform.position + camera.transform.forward * (260-target.transform.position.y)/camera.transform.forward.y;

Alternatively, you could parent the camera to an empty GameObject, set the camera's local transform to what you have now, and then just move the GameObject around.

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 Posthuman-Wizard · Dec 10, 2012 at 06:23 PM 0
Share

Thank you very much. However, when I try to perform a Vector3.Slerp(camera.transform.position, camPos, Time.time) operation in the Update so that the camera slowly moves to the new position, ins$$anonymous$$d of abruptly jumping to the position, the camera does not seem to behave correctly. Ins$$anonymous$$d, the scene begins to look "twitchy" and the distance from the camera to the ground isn't correct. What might be causing my problem?

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

10 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

Related Questions

Moving a Rotated Camera 0 Answers

Creating a trimetric camera? 0 Answers

Ortho-Isometric camera not playing nice with culling 1 Answer

Ortho camera viewport setup? 3 Answers

Isometric Camera : Get the displayed terrain portion. 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