2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WindowsMixedRealityモーションコントローラーの左右識別

Last updated at Posted at 2018-02-09

WinMRモーションコントローラーのトリガー押下時に、左右の識別で詰まったのでメモします。
現状、トリガー入力をハンドルするIInputClickHandlerのInputClickedEventDataでは、コントローラーの左右の情報が取れない?(ちゃんと調べてない)ので、gestureRecognizerを使うとうまくできました。サンプルコードは以下。

    private void Awake()
    {
        //InputClickedEventDataではどちらのコントローラーが押されたかを識別できないのでGestureRecognizerを使う
        gestureRecognizer = new GestureRecognizer();
        gestureRecognizer.Tapped += GestureRecognizer_Tapped;

        gestureRecognizer.StartCapturingGestures();
    }

    public void GestureRecognizer_Tapped(TappedEventArgs obj)
    {
        if(obj.source.handedness == InteractionSourceHandedness.Left)
        {
            Debug.Log("left Trigger");
        }

        else if (obj.source.handedness == InteractionSourceHandedness.Right)
        {
            Debug.Log("right Trigger");

        }
    }
2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?