• Unity使用陀螺仪控制Camera


    App中使用陀螺仪控制Camera:

    using UnityEngine;
    using System.Collections;

    public class cameraRotation : MonoBehaviour {

    void Start()
    {
    if (Application.platform == RuntimePlatform.Android)
    {
    Input.gyro.enabled = true;//打开陀螺仪权限
    Screen.sleepTimeout = SleepTimeout.NeverSleep;
    Input.gyro.updateInterval = 60f;
    }
    }

    void Update()
    {
    if (!ARManager.instance.attachGyro) return;
    this.transform.localRotation = CameraRotation();
    //this.transform.localRotation = Quaternion.Slerp(transform.rotation, CameraRotation(), 0.2f);
    }

    Quaternion CameraRotation()
    {
    Quaternion input = Input.gyro.attitude;
    input = Quaternion.Euler(90, 0, 0) * (new Quaternion(-input.x, -input.y, input.z, input.w));
    return input;
    }
    }

  • 相关阅读:
    python之字典操作
    python之元组操作
    初始超算
    后缀自动机
    博弈
    曼哈顿最小生成树
    莫队算法
    主席树
    [HNOI2014]世界树
    [SDOI2011]消耗战
  • 原文地址:https://www.cnblogs.com/monkeyst/p/7766772.html
Copyright © 2020-2023  润新知