Created
April 12, 2018 16:37
-
-
Save knasa21/06336ae4efdf7ba622eb1e42586c9f5e to your computer and use it in GitHub Desktop.
Androidスマホ横もちの時のカメラ回転をジャイロでできるようにするスクリプト
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