Looking-Glass / JoyconLib

Joy-Con library for Unity.
MIT License
467 stars 91 forks source link

Y and Z rotations switched #8

Open qwertyempire opened 6 years ago

qwertyempire commented 6 years ago

Hello,

When I turn the JoyCon, the y and z rotations seem to be switched, is there a way to fix this?

Thanks!

CTCaer commented 6 years ago

You can change axes and signs in the following function: https://github.com/Looking-Glass/JoyconLib/blob/master/Assets/JoyconLib_scripts/Joycon.cs#L460

ChadiHusser commented 6 years ago

Hi,

I have been trying to change axes and signs in the ProcessIMU method, but got no results. I assume I have to change j_b and k_b axis in the first_imu_packet condition then change the way they are incremented. Am I wrong? If so what should I do instead?

Thanks!

uvmarko commented 6 years ago

Hi, After some fiddling with the demo script, I ended up with this

orientation = j.GetVector();
orientation = new Quaternion(orientation.x, orientation.z, orientation.y, orientation.w);
gameObject.transform.localRotation = Quaternion.Inverse(orientation);

and either rotate it 180 degrees on the y axis or put it under a rotated game object in the hierarchy, and it'll switch the axis.

SpectralSlog commented 3 years ago

Hi, After some fiddling with the demo script, I ended up with this

orientation = j.GetVector();
orientation = new Quaternion(orientation.x, orientation.z, orientation.y, orientation.w);
gameObject.transform.localRotation = Quaternion.Inverse(orientation);

and either rotate it 180 degrees on the y axis or put it under a rotated game object in the hierarchy, and it'll switch the axis.

Where do I put this code? This is probably dead though

raytsang commented 2 years ago

gameObject.transform.rotation = orientation; gameObject.transform.Rotate(90,0,0,Space.World); //Add this line will fix the problem