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
5
Question by Glacier Games · Jun 19, 2013 at 06:41 PM · rotationeuleranglessimpleeuler

EulerAngles.x stops at 90???

Its a simple script yet I can't get it to work. Whenever I run it, transform.eulerAngles.x always stops at 90. What's up with this??!

 function Update () {
 transform.eulerAngles.x += 1;
 }

Btw, I need to be working with eulerAngles.

Update: Its almost as if unity clamps the angle between 270(or -90) and 90. I have not clamped the angle myself.

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
12
Best Answer

Answer by robertbu · Jun 19, 2013 at 06:58 PM

This issue comes up frequently. There are multiple euler angle representations for any physical representation, and Unity/Quaternions can change the representation. For example, run this code:

 function Start() {
   transform.eulerAngles = Vector3(180,0,0);
   Debug.Log(transform.eulerAngles);
 }

What you will get back is (0,180,180)...the same physical rotation but a different euler representation. One solution is to maintain your own Vector3, and treat eulerAngles as write-only.

 var v3 = Vector3.zero;
 var speed = 25.0;
 
 function Start() {
   transform.eulerAngles = v3;
 }
 
 function Update() {
     v3.x += speed * Time.deltaTime;
     transform.eulerAngles = v3;
 }
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 Glacier Games · Jun 19, 2013 at 07:24 PM 0
Share

Works like a charm! Thanks! Unity really needs to fix the whole eulerAngles deal.. This isn't the first time I ran into something like this.

avatar image robertbu · Jun 19, 2013 at 07:37 PM 2
Share

It will never be fixed. For rotations, Unity uses Quaternions for a number of valid technical reasons. Euler angles is just a representation of the Quaternion, and when you pull a euler angle back out of a quaternion, you are not guaranteed that the values will be the same as the ones you put in. In theory, you should be able to write code to normalize the rotation so that you can have an expected value, but it is just easier to maintain your own Vector3 as I've done above. And there are other possible ways to solve this problem.

avatar image Eric5h5 · Jun 19, 2013 at 08:04 PM 0
Share

Also you wouldn't want to increment the x angle by 1 every Update, since that's framerate-dependent.

avatar image robertbu · Jun 19, 2013 at 08:12 PM 0
Share

Yep. Changed the answer.

avatar image Glacier Games · Jun 20, 2013 at 10:12 PM 0
Share

Yeah, I know Eric. It just seemed like a simple way to express my issue.

Show more comments
avatar image
0

Answer by holyfot · Oct 08, 2020 at 04:03 AM

Use: transform.localRotation.eulerAngles.x or y or z instead of transform.localEulerAngles. This lets you get a full 360 range.

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

18 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

Related Questions

Is there no way to get reliable angles from a rigidbody? 2 Answers

Simple object rotation & LookAt 1 Answer

transform.eulerAngles Problem 0 Answers

How to make car land on 4 wheels and maintain speed? 0 Answers

How to properly reference a Euler? 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