Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Cambesa · Jan 06, 2017 at 02:19 PM · camerainspectoreulerangles

Inspector Euler angles deviates from Euler angles in code

Hi everyone,

I'm trying to clamp the rotation over the X axis(tilt) so you can not rotate further up than straight up and not further down then straight down. The problem is that the clamp angle seems to be between -90 and 90 if you look at the inspector but if you debug.log the euler angle, it shows that the angle is actually below 90 for every camera tilt downwards. To make it a little bit more clear, if you look straight ahead, the inspector shows 0 and the debug also shows 0. If you look straight down, the inspector shows 90 and the debug also shows 90. If you tilt even further "downwards", the inspector shows 180, but the debug log shows 0 again. See the screenshot below for an indication.

alt text

This is the code I use to show the euler angle.

 Vector3 camEuler = camT.rotation.eulerAngles;
 Debug.Log("cam angle " + camEuler.x);

In which camT is the camera transform. Does someone know why this happens?

Kind regards,

Yorick

Reference for pan,tilt,roll: alt text

inspector-shows-a-different-angle-than-it-actually.jpg (23.8 kB)
pan-tilt-roll1.png (55.3 kB)
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
1

Answer by tanoshimi · Jan 06, 2017 at 05:02 PM

There are many ways to express the same rotation: a rotation of 180 degrees around the y axis is the same as a rotation of 180 degrees around the x axis followed by 180 degrees around the z axis, for example.

Your Debug.Log only looks at the x component of the rotation but, if you look at the eulerAngle Vector as a whole, you'll probably just see that they are equivalent expressions of the same rotation.

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 Owen-Reynolds · Jan 06, 2017 at 05:07 PM 0
Share

To add to this: rotations are not stored as xyz angles. So the Inspector is your xyz settings translated into a Quaternion, then translated back to show in the Inspector.

Inspector values aren't supposed to match the ones you set. $$anonymous$$y long explanation is at taxesforcatses-dot-com/vectorW/ch4Rotation.pdf, in section 4.

avatar image Cambesa Owen-Reynolds · Jan 26, 2017 at 09:06 AM 0
Share

So it should actually be better to clamp the quaternions? I don't know exactly what the components of a quaternion are so I have no idea what to enter. For Euler it could be quite simple, just clamp the x between -90 and 90 but thanks to the conversions I can not do that. As far as I know quaternions contain a vector and scalar but I have no idea what kind of units the components are and how they relate to each other.

I will take a look at your document, thanks

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

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

Related Questions

Clamping Between Two Different Ranges 1 Answer

Inspactor Roation to Vector3 0 Answers

pressing unity play changes left and right camera parameters. How to fix? 1 Answer

I can't edit Cinemachine "Value" variable in the inspector 0 Answers

Camera X Rotation Problems 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