找回密码
 立即注册
查看: 486|回复: 0

小米VR一体机开发(三)unity 人物移动

[复制链接]
发表于 2021-3-24 19:17 | 显示全部楼层 |阅读模式
InputManager.ControllerState.IsTouching          判断是否是在触摸

InputManager.ControllerState.TouchPosition    判断触摸板位置
using MIVR;using UnityEngine;using UnityEngine.UI;public class Player : MonoBehaviour {    public GameObject cube;    void Start ()    {    }    void Update()    {        print("MIVR"+ InputManager.ControllerState.TouchPosition);        if (InputManager.ControllerState.IsTouching)        {            //上            if (InputManager.ControllerState.TouchPosition.y <= 0.25 && InputManager.ControllerState.TouchPosition.y > 0)            {                cube.transform.Translate(Vector3.forward * Time.deltaTime);            }            //下            if (InputManager.ControllerState.TouchPosition.y >= 0.75)            {                cube.transform.Translate(Vector3.back * Time.deltaTime);            }            //左            if (InputManager.ControllerState.TouchPosition.x <= 0.25 && InputManager.ControllerState.TouchPosition.x > 0)            {                cube.transform.Rotate(0, -45 * Time.deltaTime, 0);            }            //右            if (InputManager.ControllerState.TouchPosition.x >= 0.75)            {                cube.transform.Rotate(0, 45 * Time.deltaTime, 0);            }        }    }}
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-20 17:53 , Processed in 0.087019 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表