- Home /
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.
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
Tried it when i point the controller up and rotate around what would then be the x it returns much greater angles.
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.
Answer by rocketstrong1 · Aug 07, 2018 at 04:46 AM
I believe I have solved my problem with this helpful link Yaw from quaternion
Your answer
Follow this Question
Related Questions
Amplifying HMD rotation in VR 2 Answers
Rotate object based on rotation of SteamVR Controller? 2 Answers
Set a rotation relative to position between two objects. 0 Answers
How to compare two rotations from children objects 1 Answer
Change rotation of an object based on an HTC Vive Controller 1 Answer