Search Unity

Question Attach transform different for right hand/left hand

Discussion in 'XR Interaction Toolkit and Input' started by Bender_R, Feb 22, 2021.

  1. Bender_R

    Bender_R

    Joined:
    May 21, 2018
    Posts:
    115
    Hi there,

    I'm currently trying to get a right grip for a gun, with the XR Grab Interactable. For getting the right position and rotation I add an empty game object that I drag to Attach Transform.

    This is working great for my Right Hand (Oculus Touch Controller). But for my left hand, the position is too far to the left (rotation is alright).

    Moving the position of the grab game object somewhat to the right will obviously solve the problem for the left hand, but then right hand is not positioned well.

    I must be missing something. Anyone a suggestion how to solve this?

    Cheers!
     
  2. Bender_R

    Bender_R

    Joined:
    May 21, 2018
    Posts:
    115
  3. stillwind

    stillwind

    Joined:
    Jun 13, 2016
    Posts:
    13
    I'd like to know how to do this too. I check for which controller is grabbing the object by testing XRGrabInteractable.
    selectingInteractor, and then I set attachTransform with a different one for each hand, but I think it might be too late at that point, I have a force grab on a ray interactor, and it flies into the wrong position.
     
  4. Bender_R

    Bender_R

    Joined:
    May 21, 2018
    Posts:
    115
    Unfortunately I haven't found a proper solution yet. I also did try some things, like repositioning of the grab point on the 'hover' event. But this has some flaws. Also tried to reposition after grabbed. But this also isn't feeling like a solution. I have the feeling we're missing something very obvious.....
     
  5. stillwind

    stillwind

    Joined:
    Jun 13, 2016
    Posts:
    13
    I found a way to get it to work, I sub-classed XRGrabInteractable, the method that sets the transform is OnSelectEntering(), so I attach the correct transform for the hand before calling the superclass method.
     
  6. Bender_R

    Bender_R

    Joined:
    May 21, 2018
    Posts:
    115
    Nice! I'll try this.