想开发一个VR游戏,怎样让HTC Vive的手柄画出图形来触发技能

一句话回答你:去买个插件。 Asset Store想开发一个VR游戏,怎样让HTC Vive的手柄画出图形来触发技能


■网友
开关、系统菜单按钮:只有这个按钮不可以编程(默认),用来打开手柄,其实没用关的功能。在游戏中按下该按钮是调出系统默认的菜单,用来关闭,切换游戏用的。
menu按钮:默认用来打开游戏菜单。
grip按钮:用的最少的按钮,每个手柄上虽然有两个,但是是相同的。
trigger按钮:扳机按钮,用的最多,可以有力度。
pad:触摸屏+鼠标的功能,可触摸,可点击。
程序开发之综述
首先,引用HTC.UnityPlugin.Vive
view plain copy
using HTC.UnityPlugin.Vive;
using HTC.UnityPlugin.Vive;
每个按钮包括pad都有GetPress、GetPressDown、GetPressUp三种方法,用HandRole枚举来确定左右手柄,用ControllerButton枚举来确定是哪个按钮。
对于按钮,GetPressDown是按下时触发,GetPressUp是放开时触发,以上两个是个事件,GetPress是按住时一直返回ture,算是一个状态。
对于pad:
当ControllerButton.Pad时,和按钮相同。
当ControllerButton.PadTouch时,GetPressDown是接触时触发,GetPressUp是离开时触发,GetPress是接触时一直返回的状态。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HTC.UnityPlugin.Vive;
public class viveLearn : MonoBehaviour {
// Update is called once per frame
void Update () {
if (ViveInput.GetPress (HandRole.RightHand, ControllerButton.Menu)) {
Debug.Log (”menu press”);
}
if (ViveInput.GetPressUp (HandRole.RightHand, ControllerButton.Menu)) {
Debug.Log (”menu press up”);
}
if (ViveInput.GetPressDown (HandRole.RightHand, ControllerButton.Menu)) {
Debug.Log (”menu press down”);
}
}
【想开发一个VR游戏,怎样让HTC Vive的手柄画出图形来触发技能】 }

■网友
你来记录下来每段时间手柄的坐标,后台分析一下就可以了(当然复杂的可能会有点难分析。。
■网友
有一个游戏已经实现了,一个免费打骷髅的游戏。


    推荐阅读