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 /
avatar image
0
Question by unity_YYoxtjdH92iNIg · Jan 25, 2020 at 11:21 AM · rotationtextmesheulerangles

TextMeshPro display wrong rotation

i made levers to show their rotations above them and default rotations are 90 degrees but when i rotate them with raycast ..it just decrease from 90 degrees not up to 90..as you see :

alt text

alt text

and here is my code:

 using UnityEngine;
 using TMPro;
 
 public class sifreyazi : MonoBehaviour
 {
     public TextMeshPro s1;
     public GameObject st1, st2, st3, st4, st5, st6;
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     void Update()
     {
        float x1 = st1.transform.eulerAngles.x;
         s1.text = x1.ToString("0");
 
     }
 }
right.jpg (17.0 kB)
left.jpg (27.2 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
0

Answer by Bunny83 · Jan 25, 2020 at 12:49 PM

Well we have no idea about the orientation of your levers in space. Is the worldspace x axis even the axis of rotation?. How do you actually rotate your object? Is the rotating object a child of another object? If so why don't you read the localEulerAngles?


Also keep in mind that Euler angles have countless of issues. Specifically Unity uses the Y-X-Z order. Unity also does not work with euler angles internally but uses quaternions which mostly avoid all the issues that euler angles have. That means the euler angles are calculated from the actual orientation of an object.


When the X euler angle in this configuration is 90° you are actually in the gimbal lock position. If you only rotate on the X axis this isn't that important, however the X rotation is only specified in the range +-90° anyways. It's the objects "pitch" (when using aviation angles / terms). The yaw rotation (y rotation) and the roll rotation (z rotation) is in the range +-180°. The eulerangles is an overspecifed system. So it doesn't have a unique representation of a certain orientation.


For example the orientation (0,0,0) is the same as (180,180,180). Likewise if your rotation is (105,0,0) it is the same as (75,180,180). In general you shouldn't really rely on euler angles since they might not represent what you want them to represent.


Though when using a parent object and you only rotate the child object you should have no issues with local rotations if the parent already applies your offset. So have the parent rotated x =90° and the child rotate between -15° and 15° if that's the angle you're looking for.


In a more general sense such a thing as a lever position should actually be seperated from the visual representation, at least if you want to do some logic on that state.


Since we don't know anything about your usecase we can't really suggest any alternatives.

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 unity_YYoxtjdH92iNIg · Jan 25, 2020 at 04:40 PM 0
Share

Oh my god...so confusing..i am beginner at unity and coding man calm down..also my english not perfect..also yes lever child of another object

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

154 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 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

Rotate with raw gyro data. 0 Answers

Best way to rotate a door 1 Answer

Keep track of rotations beyond 360 degrees, and under 0 degrees 1 Answer

How to prevent transform.Rotate from oddly flipping other axis... 1 Answer

Store initial rotation in JavaScript 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