十一、pico+Unity交互开发教程——手指触控交互(Poke Interaction)

一、XR Poke Interactor

  1. 交互包括发起交互的对象(Interactor)和可被交互的对象(Interactable)。XR Interaction Toolkit提供了XR Poke Interactor脚本用于实现Poke功能。
  2. LeftHand ControllerRightHand Controller``物体下创建名为Poke Interactor的空物体,并添加XR Poke Interactor脚本。
  3. 设置XR Poke Interactor中的Attach Transform,在手部模型下创建代表交互点的子物体(如Poke Point),并将其拖至XR Poke Interactor脚本中的Attach Transform处。
  4. 若手部有其他Interactor,可将Poke Interactor添加到LeftHand ControllerRightHand Controller上的XR Interaction Group中,确保一个Interactor起作用时其他Interactor暂时失效。

二、与UI进行触控交互

  1. 添加Tracked Device Graphic RaycasterXR UI Input Module让UI可被交互,在Canvas上添加Tracked Device Graphic Raycaster脚本;

  2. 在EventSystem上添加XR UI Input Module脚本。

三、与物体进行交互

  1. XR Simple Interactable

    • 用红色方块代表可交互物体,添加XR Simple Interactable脚本。
    • XR Simple InteractableInteractable Events中添加事件,如在Select Entered时让方块材质变成黄色,在Hover Exited时让方块材质变回红色。这个在前面学过
    • 由于XR Simple Interactable默认会被其他Interactor触发,为避免手靠近方块时按下手柄Grip键触发Select Entered事件,可将XR Poke Interactor的Interaction Layer Mask和方块挂载的XR Simple Interactable的Interaction Layer Mask进行设置。经测试,在XRI 2.3.2版本下,可将XR Simple Interactable的Interaction Layer Mask单独设置一个层级(如"Poke"),XR Poke InteractorInteraction Layer Mask设置为Everything,使Poke Interactor单独与方块进行交互。 这个也学过;
  2. XR Poke Filter

    • 运行程序时若无法触发Poke,是因为XR Poke Interactor默认勾选了Require Poke Filter,此时能发生Poke交互的物体必须拥有XR Poke Filter组件。
    • 在方块上添加XR Poke Filter组件,可调整Poke Configuration参数,如将Poke Direction设为Negative Y,即手指从上往下触碰方块时可触发Poke

通过以上步骤,我们成功实现了Unity VR中的手指触控交互功能,为VR体验增添了更多自然和直观的交互方式。

相关推荐
爱搞虚幻的阿恺5 天前
Niagara粒子系统-超炫酷的闪电特效(加餐 纸牌螺旋上升效果)
游戏·游戏引擎
_Li.5 天前
Simulink - 6DOF (Euler Angles)
人工智能·算法·机器学习·游戏引擎·cocos2d
weixin_424294675 天前
Unity 调用Steamworks API 的 SteamUserStats.RequestCurrentStats()报错
unity·游戏引擎·steamwork
HoFunGames5 天前
Unity小地图,Easy Minimap System MT-GPS插件
unity·游戏引擎
微学AI5 天前
从云端到指尖:重构 AI 终端生态与实体交互新范式
人工智能·重构·交互
The️5 天前
Linux驱动开发之Read_Write函数
linux·运维·服务器·驱动开发·ubuntu·交互
wy3258643645 天前
Unity 新输入系统InputSystem(基本操作)
unity·c#·游戏引擎
WarPigs5 天前
着色器multi_compile笔记
unity·着色器
ECHO飞跃 0125 天前
Unity2019 本地推理 通义千问0.5-1.5B微调导入
人工智能·深度学习·unity·llama
Unity游戏资源学习屋5 天前
【Unity UI资源包】GUI Pro - Casual Game 专为休闲手游打造的专业级UI资源包
ui·unity