遊戲是學習 www.GameIsLearning.url.tw ar vr教育遊戲式學習 王啟榮 unity教學網站 行動遊戲學習平台

討論區 > Unity 教學與學習

VRTK 教學 ─ 控制器觸發事件

chijung 發表於 2018/08/22_00:07

1. 在 script 開頭加上「using VRTK;」。

2. 在 class 中加入以下程式:

  public VRTK_ControllerEvents controllerEvents;

  void OnEnable(){ controllerEvents.TriggerPressed += ControllerEvents_TriggerPressed; }

  void OnDisable(){ controllerEvents.TriggerPressed -= ControllerEvents_TriggerPressed; }

  void ControllerEvents_TriggerPressed (object sender, ControllerInteractionEventArgs e){
    print ( "Trigger Pressed !!" );
  }



建議延伸閱讀:
>> Unity SteamVR 教學-基本設定流程(以Unity 2021.2版為例)
>> VRTK 教學 ─ 基本設定
>> VRTK 教學 ─ 控制器事件名稱對應