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 Linearch · Oct 19, 2015 at 10:45 AM · rotationaxisrotation axislocallocalrotation

Get angle of rotation around local axis

Edit : Question was too long.

Ok so I have a world rotation, or say, a Transform. How can I get the rotation around its local X axis (transform.right) and local Y axis (transform.up)?

Thanks.

Comment
Add comment · Show 8
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 meat5000 ♦ · Oct 18, 2015 at 03:24 PM 0
Share

Implement a "Calibrate" Option which zeroes the current position by reading the gyro/accel and offsetting it in the calculations.

avatar image MerovingL meat5000 ♦ · Dec 13, 2016 at 07:30 AM 0
Share

Where is "Calibrate" I cant find it, google doesn't help

avatar image Linearch · Oct 18, 2015 at 10:15 PM 0
Share

I already have that. Still what I get is world rotation. for example my game is landscape. I'm laying down and turning to the side so my phone is portrait in world space. The rotation is then inversed this way (x becomes y and y becomes x). Using get orientation might do the trick but its only for per 90° angles. $$anonymous$$aybe if I can get the local Z rotation I can rotate the whole rotation so it seems like it's always in landscape world space.

btw using gameobject to simulate this is fine with me, it doesnt have to be pure scripting.

avatar image meat5000 ♦ · Oct 19, 2015 at 09:02 AM 0
Share

Detect the screen orientation and select the relevant code block accordingly.

Curiously there are two pages on screen orientation.

http://docs.unity3d.com/ScriptReference/ScreenOrientation.html

http://docs.unity3d.com/ScriptReference/Screen-orientation.html

avatar image Linearch · Oct 19, 2015 at 03:03 PM 0
Share

I also did that. I've successfully nullified Z rotation but it seems like it wasnt really helpful.

I've done several tests, and got :

  • local Z rotation is the same as world Z rotation

  • Using the projection method, if I use the local forward axis as the perpendicular vector to get the local y rotation angle, it always return the same angle as world Y rotation.

  • If I use local Up as perpendicular vector, then the result will be unafftected by local Up rotation, but other axis rotations will. This goes for all axis combinations except local forward-up mentioned just before this.

avatar image Linearch · Oct 19, 2015 at 03:06 PM 0
Share

Updated the question. Btw to simplify things I want to get the angle of the rotation around an object's local X and Y axis. localEulerangles won't do, it's relative to ita parent not its local axises

avatar image toromano Linearch · Oct 21, 2015 at 11:58 AM 0
Share

What do you mean by "I want to get the angle of the rotation around an object's local X and Y axis." local axis also rotates with gameobject. You can't get a relative rotation in its local axis. Did i get wrong ?

avatar image Linearch toromano · Oct 22, 2015 at 10:31 AM 0
Share

I thought since I can rotate around those axises they also have a time when the rotation around it is zero, and maybe I can get the amount of rotation that has been done around it. I've read a post on stackoverflow about how to get an angle around custom axis using projection, but it didnt work well for me.

Well if this is really impossible, or more like doesnt make sense, I'll just stop trying to make this work (cuz it wont)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by bjennings76 · Dec 19, 2016 at 12:37 AM

It sounds like you are looking for the object's local Euler angles:

 float localRotationX = transform.localRotation.eulerAngles.x;
 float localRotationY = transform.localRotation.eulerAngles.y;
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

7 People are following this question.

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

Related Questions

Using Local Angles to target enemy object 0 Answers

Rotation does not seem to make sense 2 Answers

Writing a simple script to rotate an object in direction of axis 0 Answers

How set rotation of a single axis 1 Answer

Rotating on other axis 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