Comments and answers for "Android Gyroscope inaccuracy problems."
http://answers.unity.com/questions/919250/android-gyroscope-inaccuracy-problems.html
The latest comments and answers for the question "Android Gyroscope inaccuracy problems."Comment by Pendantic on Pendantic's answer
http://answers.unity.com/comments/923042/view.html
Sorry this is how you subtract quaternions
result = originalRotation * Quaternion.Inverse(subtractingValue)
the reason I do direction.y = 0 is so the if the user tilts the device to the side your car shouldn't freak out and roll over, although I forgot to ask if your game is 2D and uses the x and y coordinate system to move around in which case you would want to do direction.z = 0Fri, 13 Mar 2015 14:39:24 GMTPendanticComment by DasFloX on DasFloX's answer
http://answers.unity.com/comments/921502/view.html
Doesnt work either. It says you cant divide quaternions. What exactly is the direction.y = 0 for?Wed, 11 Mar 2015 16:25:36 GMTDasFloXComment by Pendantic on Pendantic's answer
http://answers.unity.com/comments/921368/view.html
You still need an offset, so in Start
Quaternion startOffset;
void Start()
{
startOffset=Input.gyro.attitude;
}
then in he update try this
Vector3 direction = Input.gyro.attitude * Vector3.up;
//this just will take away any up or down rotation
direction.y = 0;
Quaternion rot = Quaternion.LookRotation(direction,Vector3.up);
rot *= new Quaternion(0.5f, -0.5f, 0.5f, 0.5f);
rot/=startOffset;
player.transform.rotation = Quaternion.Lerp(transform.rotation,rot,5f*Time.deltaTime);Wed, 11 Mar 2015 14:35:59 GMTPendanticComment by DasFloX on DasFloX's answer
http://answers.unity.com/comments/921298/view.html
Vector3 direction = Input.gyro.attitude * Vector3.up;
//this just will take away any up or down rotation
direction.y = 0;
Quaternion rot = Quaternion.LookRotation(direction,Vector3.up);
rot *= new Quaternion(0.5f, -0.5f, 0.5f, 0.5f);
player.transform.rotation = Quaternion.Lerp(transform.rotation,rot,5f*Time.deltaTime);Wed, 11 Mar 2015 13:24:39 GMTDasFloXComment by Pendantic on Pendantic's answer
http://answers.unity.com/comments/920933/view.html
Hmm can I can I see what you wrote?Wed, 11 Mar 2015 01:04:49 GMTPendanticComment by DasFloX on DasFloX's answer
http://answers.unity.com/comments/920677/view.html
Doesn't really work, when i multiply that value the car is still facing the same direction as before.Tue, 10 Mar 2015 19:50:52 GMTDasFloXComment by Pendantic on Pendantic's answer
http://answers.unity.com/comments/920577/view.html
you may want to parent you gameobject so that it's initial world world rotation is 0,0,0 then in start get your initial gyro quaternion as above and then divide any further rotations you get by that initial value. With quaternions multiplying is equivalent to adding and dividing is equivalent to subtraction, don't ask me whyTue, 10 Mar 2015 18:10:01 GMTPendanticComment by DasFloX on DasFloX's answer
http://answers.unity.com/comments/920564/view.html
Okay main-reason i used euler is that i don't understand how Quaternion works and Quaterion also seems very abstract to me.
One more problem is, that the player needs to have a certain starting rotation (-90, 90, 0) and i dont know how to apply that to the Quaternion.
I tried this
rot += new Quaternion(0.5f, -0.5f, 0.5f, 0.5f);
that quaternion seems to be my needed rotation according to some online converter, but it says, that you can't add quaternions together.Tue, 10 Mar 2015 17:59:02 GMTDasFloXAnswer by Pendantic
http://answers.unity.com/answers/920460/view.html
I would recommend sticking with gyro.attitude but possibly adding a lerp to smooth out those jumps you have. Also if you dealing with angles you may not want to convert to euler as there can be some weird issues with that. It looks like you want the z rotation of the device to set the Y rotation which is a little tricky but can be done. This is how you could convert it
//this returns the direction use Vector3.right if Vector3.up doesn't work
Vector3 direction = Input.gyro * Vector3.up;
//this just will take away any up or down rotation
direction.y = 0;
Quaternion rot = Quaternion.LookRotation(direction,Vector3.up);
transform.rotation = Quaternion.Lerp(transform.rotation,rot,5f*Time.deltaTime);Tue, 10 Mar 2015 16:20:31 GMTPendantic