Skip to content

Instantly share code, notes, and snippets.

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