• 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
1
Question by $$anonymous$$ · Mar 28, 2017 at 06:50 PM · vreulerangles

How do I get accurate SteamVR Vive controller X axis rotation euler values?

As the title says, I need to find the current x rotation of a Vive controller.

I'm currently able to get accurate Y and Z rotation values, but not X, the values will be going down, get to maybe 270 and then go up again to 360 and then go down again until it loops around to 270 at which point it'll go up again until going down once it again get's to 360.

The end result being that the controller rotation is 360 at two points in a full rotation. At opposite ends of the rotation too and the rest of the rotation appears accurate, meaning that when it is facing down the value will be on the lower side of 180 and when it is facing up it will be above that. But 180 is never actually seen because it is 360 at that point for some reason.

I'm not sure if it's possible to understand exactly what I mean from the above statement, but the point is that the X rotation Euler angles are inaccurate.

To elaborate on what I need, a good analogy would be, if the controller was the headset and it was strapped to the users head, I would need values to represent how far left or right the user is looking and how far up and down the user is looking. Right now the left and right value is accurate, but what I'm assuming must be the up and down value doesn't work properly.

The code I'm using right now is public Vector3 Angle { get { return controller.transform.rot.eulerAngles; } }

And then a simple Debug.Log(Angle) to print that out at every update, which is how I checked what the values were in response to my rotation. Making sure that when testing any specific axis I was only turning the controller in that one axis instead of two at once which would give weird results.

Thanks in advance!

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 aitchest-of-dees · Oct 11, 2017 at 07:44 PM 0
Share

Did you ever find a solution to this? I'm running into the same issue.

avatar image $$anonymous$$ aitchest-of-dees · Oct 11, 2017 at 10:25 PM 0
Share

Sadly nope, abandoned the project

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by BULK_BICEPS · Apr 16, 2018 at 03:34 AM

This issue only seems to affect the Euler angles, not the Quaternion itself. Here is a working solution!

 Quaternion newRotation = Quaternion.identity; // Create new quaternion with no rotation
 newRotation.x = transform.rotation.x; // Get only the X rotation from the controllers quaternion
 
 // Output the x rotation. It should be a value between -1 and 1
 Debug.Log ("newRotation.x: " + newRotation.x);

 // Convert to a value between 0 and 360
 float xEuler = (newRotation.x + 1) * 180

 // Output the x rotation as a Euler angle
 Debug.Log ("xEuler: " + xEuler);

For whatever reason, this doesn't have the issue where it shows the incorrect value when rotating.

Credit to "wheatgrinder" from this reddit post

https://www.reddit.com/r/Vive/comments/6toiem/how_to_get_each_axis_rotation_from_vive/dlmf8v3/

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

115 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

Related Questions

Storing a rotation variable, does it store the value of rotation or does it update whenever the object rotates? 1 Answer

Different rotation behaviour in regular playmode vs. step-by-step? 0 Answers

Rotating an object in script 0 Answers

Convert movement direction into rotation? 0 Answers

Can I create a script that when I target an object the player then teleports? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges