Skip to content

Instantly share code, notes, and snippets.

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