首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在VRTK 4 Beta (联合)中添加来自VR控制器的按钮输入?

如何在VRTK 4 Beta (联合)中添加来自VR控制器的按钮输入?
EN

Stack Overflow用户
提问于 2020-04-24 15:22:57
回答 1查看 485关注 0票数 0

我想使用按钮在我的团结场景中触发动作,但当我按下按钮时,我想不出如何调用相应的方法。我使用VRTK 4 (beta),无法找到任何有用的文档或回答它的问题。

EN

回答 1

Stack Overflow用户

发布于 2020-04-24 15:22:57

VRTK版本4.0 Beta

https://docs.unity3d.com/Manual/xr_input.html

  • Check (相应的特性类型),
  1. 从这个表中查找设备的按钮"Legacy Input Index“。
    • 如果是按钮,则不需要添加“项目设置->输入”列表。如果是轴,则需要将其添加到“项目设置->输入”列表中(通过增加列表的大小)。查看其他(类似的)按钮并复制scheme:

代码语言:javascript
复制
Example Left Oculus Trigger:
Name: VRTK_Axis9_LeftTrigger *[Adapt your name]*
[...] Gravity: 0
Dead: 0.001
Sensitivity: 1
[...]
Type: Joystick Axis
Axis: 9th axis (Joysticks) *[Enter the index number you've looked up before]*
Joy Num: Get Motion from all Joysticks

在这里查找属性及其描述:https://docs.unity3d.com/Manual/class-InputManager.html

  1. 在统一中创建了一个新的GameObject。如果是Button:
      • 添加脚本。将“您已查找的number索引号”设置为键code.

代码语言:javascript
复制
- If it is an 1DAxis:  
    - and you want its value (float):  
        - add the VRTK UnityAxis1DAction script. Set the name from the "Project Settings -> Input" (in the example "VRTK\_Axis9\_LeftTrigger") as axis name.

代码语言:javascript
复制
    - and you want its pressed/released (bool):  
        - add the VRTK UnityAxis1DAction script. Set the name from the "Project Settings -> Input" (in the example "VRTK\_Axis9\_LeftTrigger") as axis name.
        - add the Zinnia FloatToBoolean script. In the "Transformed" field, reference the GameObject itself (press + to add). Choose BooleanAction.Receive.
        - add the Zinnia BooleanAction script. In the "Activated" field, reference the GameObject that shall react to the button state (press + to add) and choose the method, that shall be called, when the button is pressed. (Repeat for the "Deactivated" field with the method, that shall be called, when the button is released.)

代码语言:javascript
复制
- If it is an 2DAxis:  
    - and you want its values:  
        - add the VRTK UnityAxis2DAction script. Set the names from the "Project Settings -> Input" from your x and y axes to the corresponding X axis name and Y axis name.

我希望这能帮助你开始使用新的VRTK版本!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61411800

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档