Unity陀螺仪应用
来源:互联网 发布:ic卡扇区数据分析转换 编辑:程序博客网 时间:2024/05/22 05:04
Unity里面关于陀螺仪的文章
using UnityEngine;using System.Collections;//摄像机 陀螺仪转动public class IphoneGyro : MonoBehaviour{ //bool gyroBool; Gyroscope gyro; Quaternion quatMult; Quaternion quatMap; UILabel ul; GameObject player; GameObject camParent; void Awake() { player = GameObject.Find("Player"); // find the current parent of the camera's transform Transform currentParent = transform.parent; // instantiate a new transform camParent = new GameObject("camParent"); // match the transform to the camera position camParent.transform.position = transform.position; // make the new transform the parent of the camera transform transform.parent = camParent.transform; // make the original parent the grandparent of the camera transform //camParent.transform.parent = currentParent; // instantiate a new transform GameObject camGrandparent = new GameObject("camGrandParent"); // match the transform to the camera position camGrandparent.transform.position = transform.position; // make the new transform the parent of the camera transform camParent.transform.parent = camGrandparent.transform; // make the original parent the grandparent of the camera transform camGrandparent.transform.parent = currentParent; //gyroBool = true; //if (gyroBool) { gyro = Input.gyro; ul = GameObject.Find("Rotation").GetComponent<UILabel>(); gyro.enabled = true; camParent.transform.eulerAngles = new Vector3(90,0, 0); quatMult = new Quaternion(0, 0, 1, 0); } void Update() { quatMap = new Quaternion(gyro.attitude.x, gyro.attitude.y, gyro.attitude.z, gyro.attitude.w); Quaternion qt=quatMap * quatMult; transform.localRotation =qt; ul.text = "Rotation:" + transform.localRotation + "player" + player.transform.localRotation; } }
0 0
- Unity陀螺仪应用
- Unity陀螺仪
- Unity陀螺仪
- Unity陀螺仪
- unity陀螺仪
- Unity 陀螺仪。。哈哈。。。。
- Unity陀螺仪功能
- unity 陀螺仪的脚本
- unity陀螺仪参数详解
- Unity陀螺仪功能
- Unity中陀螺仪控制
- 【Unity】Unity调用手机陀螺仪
- Unity 使用陀螺仪观察场景
- unity之陀螺仪和指南针
- Unity-陀螺仪控制Camera旋转
- 陀螺仪原理与应用
- 单片机应用-陀螺仪&加速度玩法
- unity 只有一个方向旋转的陀螺仪
- Spark读取Hbase中的数据
- HDU-4738-Caocao's Bridges(割边)
- Android day3:Java浮点类型、转义字符、布尔类型
- sql 相关
- 数据库设计
- Unity陀螺仪应用
- C++上机实验6--数组分离
- 关于margin叠加问题
- 第十三周項目-阅读项目-4
- 《重温最美古诗词》
- 软件设计原则--开放封闭原则
- JQuery、JSON、Ajax在Servlet中的应用
- 树、森林与二叉树的相互转换
- Linux 系列(二)——FTP安装手册