This script has been designed to be easily customizable and to obtain the smoothest and most flexible rotation possible. Tested on Android.
In order to personalize this script to match with your case, you just have to change which gyroscope axis control which object one. To do that, you have to edit the ApplyGyroRotation function :
Quaternion tempGyroRotation = new Quaternion(
offsetRotation.x * curSpeed,
0f * curSpeed,
offsetRotation.y * curSpeed,
offsetRotation.w * curSpeed
);
This script contain few parameters editable through Unity inspector :
- Speed : change rotation speed of the object
- Smoothing : must be between 0 and 1, it changes the delay for the object in order to reach its final position
- Wait Gyro Initialization : used to enable or disable the initial delay to wait gyroscope activation
- Wait Gyro Initialization Duration : duration of the initial delay in seconds
- Debug : displays an overlay which includes a lot of information such as: real-time gyro attitude, offset, initial position ect...
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!