Unity中陀螺仪控制
来源:互联网 发布:重庆话翻译器软件 编辑:程序博客网 时间:2024/05/24 00:57
这里就直接上代码,代码带有注释,后续引用在更新!
private const float lowPassFilterFactor = 0.2f; Gyroscope go; bool gyinfo; protected void Start() { gyinfo = SystemInfo.supportsGyroscope; go = Input.gyro; //设置设备陀螺仪的开启/关闭状态,使用陀螺仪功能必须设置为 true Input.gyro.enabled = true; //获取设备重力加速度向量 Vector3 deviceGravity = Input.gyro.gravity; //设备的旋转速度,返回结果为x,y,z轴的旋转速度,单位为(弧度/秒) Vector3 rotationVelocity = Input.gyro.rotationRate; //获取更加精确的旋转 Vector3 rotationVelocity2 = Input.gyro.rotationRateUnbiased; //设置陀螺仪的更新检索时间,即隔 0.1秒更新一次 Input.gyro.updateInterval = 0.1f; //获取移除重力加速度后设备的加速度 Vector3 acceleration = Input.gyro.userAcceleration; } protected void Update() { //Input.gyro.attitude 返回值为 Quaternion类型,即设备旋转欧拉角 //transform.rotation = Quaternion.Slerp(transform.rotation, Input.gyro.attitude, lowPassFilterFactor); transform.rotation = Input.gyro.attitude * new Quaternion(0, 0, 1, 0); //transform.rotation=Quaternion.Euler(Input.gyro.rotationRateUnbiased); }
阅读全文
0 0
- Unity中陀螺仪控制
- Unity-陀螺仪控制Camera旋转
- Unity陀螺仪
- Unity陀螺仪
- Unity陀螺仪
- unity陀螺仪
- 多旋翼控制中陀螺仪的作用
- 【C#】AR unity 陀螺仪控制摄像机 真实方向
- Unity实现对移动端的陀螺仪控制
- 【unity实用技能】unity3d 陀螺仪控制camera移动旋转
- Unity 陀螺仪。。哈哈。。。。
- Unity陀螺仪功能
- unity 陀螺仪的脚本
- Unity陀螺仪应用
- unity陀螺仪参数详解
- Unity陀螺仪功能
- 【Unity】Unity调用手机陀螺仪
- Unity3D中通过陀螺仪来控制摄像机的旋转
- 问题收集篇-负载均衡四层和七层的区别
- JSP交互---分页查询(基本分页查询)
- test2
- mysql中update的low_priority
- Java 自定义异常
- Unity中陀螺仪控制
- 内置对象 Session
- 【C#】List.Find
- Armstrong公理系统
- Redis原子计数器incr,防止并发请求
- redhad linux下安装mysql
- 杂记
- spring boot:如何优雅的使用mybatis
- Xcode 用Ad_Hoc方式打包