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 JPB18 · Jun 01, 2012 at 04:10 PM · c#camerarotateorientation

Get object orientation

Hi there!

I'm here to ask if it's possible to store an object (camera) orientation into a variable, so I can later use it to "match" another object (another camera) with it?

The objective is to make a "smooth transition" when I advance to the next "slide" in the scene (I'm creating a presentation based on Prezi "Zoom In Presentation", but in 3D), knowing that the second set of objects is in a different direction than the first set...

Thank in advance!

JPB18

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

3 Replies

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

Answer by hathol · Jun 01, 2012 at 04:20 PM

Yepp. A camera (like any other gameobject in unity) has a transform property that stores position, orientation and scaling of the object. If you are only interested in the orientation, store transform.rotation (type Quaternion). You can also smoothly interpolate between the two orientations by using Quaternion.Slerp()

Further info: http://unity3d.com/support/documentation/ScriptReference/Transform.html http://unity3d.com/support/documentation/ScriptReference/Quaternion.html

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
avatar image
0

Answer by Berenger · Jun 01, 2012 at 04:18 PM

I suggest you create an empty gameobject for each positions - orientation you will have. Set them up properly in the editor, declare an array of transform in your script and then you can access the information you need at any time.

If you still want to only store a rotation though, declare a quaternion and affect you're camera's rotation to it.

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
avatar image
0

Answer by Wolfram · Jun 01, 2012 at 04:23 PM

The best approach would be to create an empty GameObject for every pos/rot/scale setting you want to store. The additional advantage is, you could create/place them beforehand in your scene, and modify them with the transform handles, or with Ctrl-Shift-F and "AlignViewToSelected" etc.

As there are no Copy methods for the whole transform, you'd have to store/load the values individually. For example, to store the values, you'd do something like:

 Transform mainCamTrans=Camera.main.transform;
 myTransfomStorage[x].position=mainCamTrans.position;
 myTransfomStorage[x].rotation=mainCamTrans.rotation;
 myTransfomStorage[x].localScale=mainCamTrans.localScale; // there is no reliable global scale, but it's irrelevant for Cameras anyway, only for objects
 

Note you'd need special treatment (i.e., a small script attached to that empty GameObject) for additional camera settings such as FoV, near/far clip, ...

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 Wolfram · Jun 01, 2012 at 04:24 PM 0
Share

Damn, too slow ^^

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Functions via camera rotations... 1 Answer

Sprinting camera movement? (C#) 1 Answer

Orbit 2D camera around circle but keep lookat towards z axis 1 Answer

Zoom in on object and make other objects disappear on zoom?,Zoom in on object and make other objects disappear 0 Answers

Multiple Cars not working 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