This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gyro camera rotation for Android, tested in Unity 2019.3.2 for API level 28, in landscape left orientation. | |
// Extended to include X and Z axis when claibrating, so you can re-center when looking in any direction, and at a variable speed. | |
// Attach this script to the parent GameObject of your camera. To re-center, from your main script, call CalibrateAngle, set a bool "letsGoToCenter" to true, a bool "goToCenterSlowly" to true or false, and a string "centerRotSpeed" to slow or fast. | |
// centerRotSpeed is ignored when goToCenterSlowly is false. You can use "Unity Remote 5" in the Play store to test Android gyro in Unity editor. | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class GyroCamera : MonoBehaviour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
045295911d46eee1abf98d3b7ef465ff2e62f6051df513a4a2eb52461ecac6039784a15da5288fc76788b9a13458dc0074030d61c64495809104d4a4bed98ce8ae |