• 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
Question by rocketstrong1 · Aug 06, 2018 at 04:50 AM · vrquaternionvectors

Getting the rotation around the vector3.up.

 Quaternion target = new Quaternion(transform.rotation.x, (LeftController.rotation.y + RightController.rotation.y)/2,transform.rotation.z, (LeftController.rotation.w + RightController.rotation.w)/2);
 transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 1.5f);

This is my method for guessing body rotation in VR it kind of works but has weird rotation at specific angles. I use the W and Y components of a Quaternion.

I am trying to find the "universal" vertical axis of the controller regardless of its other local axis's. Now i'm aware that not everyone will understand what I mean when I say this, so I have drawn up a quick representation for what I mean when I say "universal" axis and local axis.

Diagram

untitled.png (34.7 kB)
Comment

People who like this

0 Show 3
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 bobisgod234 · Aug 06, 2018 at 05:17 AM 0
Share

Could you perhaps flatten and normalize local Z/X axis, then use Vector3.SignedAngle?

Something like

 Vector3 flatForward = target.forward;
 flatForward.y = 0;
 float angle = Vector3.SignedAngle(Vector3.forward, flatForward.normalized(), Vector3.up);

Should get you the angle of the object around the global Y axis, while allowing you to tilt the object around X and Z

avatar image rocketstrong1 bobisgod234 · Aug 06, 2018 at 06:52 AM 0
Share

Tried it when i point the controller up and rotate around what would then be the x it returns much greater angles.

avatar image hexagonius · Aug 07, 2018 at 04:17 AM 0
Share

to ne it looks as if with vertical axis you mean Vector3.up in world space. if you're interested in that axis in local space just InverseTransformDirection it into the objects transform.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by rocketstrong1 · Aug 07, 2018 at 04:46 AM

I believe I have solved my problem with this helpful link Yaw from quaternion

Comment

People who like this

0 Show 0 · 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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

118 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

Related Questions

Change rotation of an object based on an HTC Vive Controller 1 Answer

How to fly in Controller's forward direction? 1 Answer

Camera viewport transformation from one world to the rotated world. 1 Answer

VR Physics Hands Rotate In Opposite Direction 1 Answer

Using a VR controller as a joystick 0 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