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 Harry64 · Aug 10, 2014 at 09:16 PM · rotationrotateaxiseulerangles

how to know if an axis has been full rotated?

I dont know how to get this done...

I rotate a object around its Y axis.(via mouse but that is not important)

I have a java script on that object that reads the actual localRotation.eulerAngles.y.

I need to know how often it is rotated around its axis. but if it gets over 359 it sets itselfe to 0 and backwards. If the var could get over 360 degree or under -360 that would help...

Comment
Add comment · Show 2
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 robertbu · Aug 10, 2014 at 09:24 PM 0
Share

How are you rotating it? If a single script is doing the rotation, then just save the rotational value in a script (i.e. don't read it from eulerAngles). It is difficult to give you a specific instruction without see your rotation code. You can also count the times the forward vector flips from front to back using Vector3.Dot or Vector3.Angle.

avatar image Harry64 · Aug 10, 2014 at 09:36 PM 0
Share

I want to create a combination lock for a save ingame and I want that the player needs to move its mouse in a circle to dial the correct code. I found a solution to that. I use the mouse XY coordinates to move a empty in a vector 2 matrix around that is aglined to the combination lock. the distance of the empty is clamped so it cannot be somewhere else. in the center of the lock is also a empty that has a transform.LookAt that looks at the other empty.

in my other script I read that rotation of that lookat empty and apply it to my visible dial objects z axis.

1 Reply

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

Answer by Harry64 · Aug 10, 2014 at 10:32 PM

hah I found a solution!!! In my case I convert the eulerAngles to numbers from 0 to 99. but it can also be done if using degrees.

     var diffOfRot : int = 0;
     
     if(oldRotOfDial > newRotOfDial)
     {
         diffOfRot = oldRotOfDial - newRotOfDial;
         if(diffOfRot > 50)
             if(fullRotations != 0)
                 fullRotations++;
     }
     
     if(oldRotOfDial < newRotOfDial)
     {
         diffOfRot = newRotOfDial - oldRotOfDial;
         if(diffOfRot > 50)
             if(fullRotations != -4)
                 fullRotations--;
     }


I simply make in my update function a var at the top that saves the current rotation before it will be changed in this update function. and because the rotation goes from 359 to 0 or 0 to 359 ( in my case from 99 to 0 and 0 to 99) I can make these if conditions that calculate if the difference is too high then a full rotation has happen and I can also see in which direction it was rotated. still there is a bug if the rotation starts at 0 and I would rotate backwards then it would say I rotated -1 but in my case this does not bother me.

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

21 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

Related Questions

Mathf.Clamp acts strange when going below 0 1 Answer

Need help with rotation script. 1 Answer

Rotating Player Controller locally or globally. 0 Answers

Object wont rotate in the opposite direction 1 Answer

Instantiate a rotated object 4 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