Last active
April 12, 2018 16:53
-
-
Save knasa21/4b9dc62d4c5818585cd1064437cc94c6 to your computer and use it in GitHub Desktop.
スマホ横もちの時のカメラ回転をジャイロでできるようにするスクリプト。
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class CameraGyro : MonoBehaviour | |
{ | |
void Start() | |
{ | |
Input.gyro.enabled = true; | |
} | |
void Update() | |
{ | |
transform.rotation = Quaternion.Euler(0, 0, -180) * Quaternion.Euler(-90, 0, 0) * Input.gyro.attitude * Quaternion.Euler(0, 0, 180); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment