首页 > 解决方案 > 如何使用 Oculus Touch GazeRing 销毁 GameObject?

问题描述

我将 Oculus VR 集成到一个简单的场景中,该场景基本上只包含一个球体:

现在我想在使用右手 Oculus Touch 设备点选球体时“摧毁”球体。Blue GazeRing 挂在 RightHandAnchor 下方。

见截图 1

Sphere,名为 Ball,配置如下: sphere 游戏对象的配置

InputManager GameObject 有一个组件“控制器输入(脚本)”:

public class ControllerInput : MonoBehaviour {

public Transform pointerTransform;
 void Update () {
 if (OVRInput.Get(OVRInput.Button.SecondaryHandTrigger))
 {
     RaycastPointer();
 }
}
private void RaycastPointer()
 {
     RaycastHit selection;
     if (Physics.Raycast(pointerTransform.position,pointerTransform.forward, 
     out selection)) 
          {
             if (selection.collider.gameObject.CompareTag ("Ball")) 
             {    
             Destroy(selection.collider.gameObject);
             }
         }
    }
 }

作为变量pointerTransform,给出了GazeRing。

但是,如果我尝试用触发按钮“射击”球体。什么都没发生。

任何人都可以建议吗?

提前致谢!

标签: unity3doculus

解决方案


推荐阅读