Search Unity

How to reset attachment point of VR grab

Discussion in 'AR/VR (XR) Discussion' started by England, Jun 10, 2019.

  1. England

    England

    Joined:
    Aug 18, 2014
    Posts:
    2
    HI there, I wondered if anyone can help me please?
    I have am object (a door) that the user can open, and when they release it, it slowly closes itself (using a Rotate, essentially).

    But when the user grabs the door again, it appears to snap back to its last know grab position. So I am keen to see if there is a way that I can clear / remove the last attachment position or not (or if there is a better way)?

    Thanks in advance!
     
  2. Scorpyon

    Scorpyon

    Joined:
    Jun 14, 2013
    Posts:
    2
    I had a little look into this and discovered that the issue appears to be the "outer angle" property that is stored on the Circular Drive.
    Using the standard SteamVR setup, when you release an object, the Circular Drive stops updating this property (which tracks the last recorded circular rotation angle where it was when it was last grabbed).
    Then if you go on to rotate the object manually through code, etc, and then grab the object again, it resets that object to the rotation it had stored in the property, hence why there is a sudden jump back to its last position.
    You need to update this property to match whichever angle the object is rotated to before being grabbed. This should fix the issue.
     
    Darksunrise957 likes this.
  3. England

    England

    Joined:
    Aug 18, 2014
    Posts:
    2
    Thank you!
    This appears to have been exactly the issue. I reset the outer angle back to 0 when the door closes and now the grab seems to work as expected.
    Great! :)
     
  4. Scorpyon

    Scorpyon

    Joined:
    Jun 14, 2013
    Posts:
    2
    No problem :)
     
  5. Darksunrise957

    Darksunrise957

    Joined:
    Jul 1, 2015
    Posts:
    15
    Wow, thanks. Helped me with an issue I was having a lot of trouble with!