Search Unity

Question XR Grab Interactable + Hinge Joint = Extremely Glitchy Door

Discussion in 'XR Interaction Toolkit and Input' started by harmakhis, Feb 11, 2021.

  1. harmakhis

    harmakhis

    Joined:
    Nov 15, 2019
    Posts:
    8
    I've implemented Valem's "Door, Lever, Drawer" system at least a dozen times over the past few days, trying to get a good result. In a nutshell:

    • Take a door mesh (doesn't matter if it's just a flattened Cube or a Blender asset)
    • Make it the parent of a handle mesh, which has a Box Collider component attached
    • Add an XR Grab Interactable component to the door; drag the handle's Box Collider to its Colliders array, and change Movement Type to "Velocity Tracking,"
    • Attach a Hinge Joint component to the door; set the correct axis (X: 0, Y: 1, Z: 0); position the Anchor correctly (basically, as it would be set in the real world, centered vertically and on the edge of the door), set the Angular Limits to [0, 100] (or whatever), and
    • Set the door (and children) to a Grab layer I created for my interactables

    The problem is the resultant glitchiness of the door. It swings along the correct axis as it should, but--with or without an Attach Transform on the XR Grab Interactable--the door often glitches positionally, as if it's trying to follow the exact position of the player's hand (rather than being confined to its hinge), sometimes ending up embedded halfway in the refrigerator.

    It operates perfectly in a very narrow range of motion, but is extremely easy to break.

    Does anyone know of a solution for this, or am I taking the wrong approach to door implementation in VR? I've scoured Unity's documentation for each component involved (full of question-begging explanations like "Smooth rotation: sets the smoothing of the rotation," as though rotation smoothing is a fully self-explanatory concept), tweaked every value that seems relevant and many that don't, and searched all over for a solution.
     
    Last edited: Feb 13, 2021
    DerWarzkopf likes this.
  2. Simianosaurus

    Simianosaurus

    Joined:
    Feb 14, 2013
    Posts:
    14
    I've followed that recently and didn't have much of an issue, but I 'could' definitely break it.

    I need solid hinges, and after looking into it, it 'seems' to be an issue with hinges (or rather how physics work) rather than XR.

    It feels like it's impossible to ensure it 'never' happens, which is odd as I thought I'd have seen it more in released games, so they must be doing something different.

    However the info on this page did help a fair bit :
    https://docs.unity3d.com/Manual/RagdollStability.html
     
    harmakhis likes this.
  3. unity_valink

    unity_valink

    Joined:
    Jan 25, 2019
    Posts:
    2
    Hi @harmakhis ,
    I also spent some time on VR Grab and joints to make my own door / lever / joystick with the XR Interaction Toolkit.

    Using this method :
    (the same video as you), when I grab a **GameObject** with both **XR Grab interactable** and a **Hinge joint or a Configurable joint** the GameObject :
    - tremble a little when moving it (it looks not stable at all)
    - teleport itself in random positions when my **direct interactor** move away while stile holding it.

    Using this method :
    ,
    The door is very stable but is also very slow to look at my controller position when grabbing it. I couldn't find any way to make it more nervous / responsive.

    I tried so many components settings and apply different approaches from tutorials but never achieve my original goal.
    I'm also considering writing a simple script with a "look at" function and some angular restrictions ; if joints still leads nowhere...

    I'll defo give a try with the link provided by @Simianosaurus (thanks).
    Let me know if you get somewhere ; I will too.

    Valink
     
    harmakhis likes this.
  4. harmakhis

    harmakhis

    Joined:
    Nov 15, 2019
    Posts:
    8
    Thanks for the response! I was excited when I read over the link you posted, because I hadn't visited it and thought there might be some promise in upping the Default Solver Iterations. (I'd disabled pre-processing already, which was mentioned in the documentation on Hinge Joints.)

    I didn't notice any improvement on implementing any of the suggestions, though, whether one at a time or all simultaneously. I think I'm gonna put this particular problem on the back-burner for a while, and see if this thread gets any more definitive solutions. The door in its current state wouldn't make it pass a first brush with QA. Way too easy to break.

    If I happen to make any progress on it, I'll definitely update here.
     
  5. harmakhis

    harmakhis

    Joined:
    Nov 15, 2019
    Posts:
    8
    Awesome! Sounds like you're noticing the exact type of behavior that I am. At least I'm not crazy!

    I'm gonna take a break and move onto some different problems, and keep my eye on this thread in the meantime.

    I'll definitely update here if I make any progress.
     
  6. unity_valink

    unity_valink

    Joined:
    Jan 25, 2019
    Posts:
    2
    I opened a thread few days ago about this issue (not sure about if it's the good location ; not very active and style seems broken) : https://answers.unity.com/questions/1812186/xr-grab-and-unity-joints-issue.html

    I tried all settings from https://docs.unity3d.com/Manual/RagdollStability.html , and got better results with projection mode (https://docs.unity3d.com/ScriptReference/ConfigurableJoint-projectionMode.html) on position and rotation and the associated position to 0. (to see the setting use configurable joint instead of hinge one) : The joystick is now teleporting only in rotation and no more in position. (My Joint preprocessing is disabled).

    Here our issue in video :
    (First joystick unstable : vibrate and get crazy when holding it away. Second joystick very slow at getting at controller position).
     
  7. Simianosaurus

    Simianosaurus

    Joined:
    Feb 14, 2013
    Posts:
    14
    I'm attempting to flip this on it's head.
    So instead of making a second handle that we grab and make the actual handle move toward that, I'm making a second hand that moves towards the controller.
    This will mean that my hand object should stay
    and make it so that the hand object itself moves with velocity towards the controller position, and it is the hand object that does the grabbin.
    This way, if I move my hand too quick the
    So, that second 'door' video gave me an idea.

    Rather than having a fake handle on the door that we grab and the real handle accelerates to it, how about we have a fake hand that accelerates towards our controller.

    This would mean that we don't see any issues work our in game hand pulling off the handle as we are seeing a virtual one in the correct place.
    It does mean the in game hand might lag behind the real one slightly when we move quickly, but I don't think that will be an issue.
    Also, it means our hand could be given a collider and collide with other objects in the scene.

    I liked this idea so have given it a go.
    I'll see if I can upload a vid.
     
  8. Simianosaurus

    Simianosaurus

    Joined:
    Feb 14, 2013
    Posts:
    14
    Had to do it on YouTube.


    It's a little buggy atm, but hopefully nothing I can't fix.

    This uses a virtual hand that moves towards the position of the VR controller.
    The benefits of this are:
    * The hand can collide with other VR objects (as opposed to your real hand)
    * It acts as a buffer between your hand and the physics objects work joints, so they should no longer glitch and break when you move very fast whilst holding them.

    After doing that I realised the script I'd written could be used to drive the positions of the fingers on a ragdoll hand. So I have that a test too.
    The benefits of that are :
    * Each finger can now be moved by forces.
    * Pushing you hand against a surface flattens itself to the surface (or bends itself around it depending on the shape)
    * I can trigger pose anims for things like grab, that will make the hands naturally grab objects.

    Note that in this video, I am interacting with the lever, drawers and door, but there is no specific 'grab' script, just one to play an aim and the rest is physics.

    Things to look at further are:
    * Improving joints (esc. the broken ring finger)
    holding onto things works better.
    * Fix rotation glitch on fingers. Something is causing them (esp. the thumb to rotate when not intended)
    * Stop hand snapping through objects when the contrller goes so far through.
    * Add friction to finger tips (currently near 0), so grab things works better.
    * Make grab blend based on amount of grip coming from the controller rather than toggling it when fully pressed.
     
    LynnWellin, wm-VR and harmakhis like this.
  9. harmakhis

    harmakhis

    Joined:
    Nov 15, 2019
    Posts:
    8
    This looks pretty incredible. It seems to solve a bunch of issues I've seen by implementing other approaches (e.g., Valem's) that I've found online. Two of the big ones:

    - Hands don't pass through other meshes, instead deforming (mostly) realistically
    - I didn't notice any of the glitchy door/drawer behavior I've noticed, and physics in general look incredibly smooth

    I was hoping to see you pick up the pistol on the table to see how the hand behaves when gripping objects. I'm guessing you don't need to create Attach Transforms to position the grip using your approach, or write poses for each individual object.

    I was able to follow the idea behind your approach, but I'm about a month and a half into my first real, sustained effort at learning Unity, so I could probably implement about 2% of this on my own. If you could point me to any tutorials or good learning material that could help push me in this direction, I'd be hugely appreciative.

    In any case, great work!
     
  10. Simianosaurus

    Simianosaurus

    Joined:
    Feb 14, 2013
    Posts:
    14
    Thanks.
    Yeah, the gun only has box collision at the moment.

    Holding actually complex objects like that may prove tricky with this method, as the fingers have to get into an unusual shape.
    That's an issue for future me to resolve though.
    Plenty to do before I get on with that. :D

    As to where to start, essentially do what is in that door video, but replace the visible door handle with a mesh for your hand.
    You will have to resolve position and orientation to match that of the controller with physics (velocity).

    Just had a look for any similar tutorials and this one looks to do it quite well.



    I definitely think seperating the controller from your hands is the way to go though as the controller movements can break all physical boundaries within the game which will break any simulation.
     
    adamgffrd and harmakhis like this.
  11. harmakhis

    harmakhis

    Joined:
    Nov 15, 2019
    Posts:
    8
    This is something I hadn't picked up on yet, and it seems like it explains virtually every problem I've encountered the past week. I wish I could attach it to the top of this thread in bold.

    I've been working through VR with Andrew's videos recently, but hadn't watched this particular one. Gonna work through it and give your approach a try.

    Thanks again!

    (@unity_valink, I thought I'd give you a mention to make sure you caught the past couple entries on this thread.)
     
    adamgffrd and Simianosaurus like this.
  12. zajcev-bb

    zajcev-bb

    Joined:
    Aug 14, 2020
    Posts:
    4
    i did encounter the very same problem. extremely glitchy doors.

    i got it working using this solution: https://www.youtube.com/watch?time_continue=68&v=3cJ_uq1m-dg&feature=emb_logo
    do not forget to set frame as kinematic, turn off gravity, doors: enable gravity, both handles: turn off gravity, turn off kinematic and set movement type to velocity tracking on grab handle

    BUT
    1: doors are acting wierd when i get close to them.. they kinda rotate in every axis to get close to the hinge anchor instead of stoping RIG from getting closer and closer.
    and 2: hand animation gets buggy when "hide controller on select" is checked... does not return to state from before the selection.
     
    MongiChan likes this.
  13. LynnWellin

    LynnWellin

    Joined:
    Jun 30, 2019
    Posts:
    1
    What's underlying logic behind the finger positioning?
     
  14. alaget

    alaget

    Joined:
    Nov 29, 2021
    Posts:
    3
    Not sure if this helps anyone but i had the same problem where i could rip apart the joint if i moved my hand to far away while still holding on.

    But the thing i wanted was to loose the grip if i moved to far.
    I achived this by simply enlarging the collider of the grip when selecting it. By unchecking "Keep Selected Target Valid" on the "XR Direct Interactor" as soon as my hand colliders move outside the grip-collider, then it would "loose grip" and the grip-collider return to its original size. As seen in the video.

     
    Last edited: Nov 8, 2022
  15. daibak08

    daibak08

    Joined:
    Jul 29, 2019
    Posts:
    1
    Not sure if anyone has mentioned it and I missed it but... I had the same problem.

    I completely fixed it by having the door/drawer/lever model be a child to a parent pivot point which has a fixed joint on it! (the rigid bodies for the pivots do not use gravity and is kinematic). I also used 'continuous' on all of my rigid body collision detection.

    This stopped the doors/levers/drawers from breaking when outside of that 'perfect narrow range'. Hope this helps!
     
  16. rahebn

    rahebn

    Joined:
    Oct 30, 2012
    Posts:
    6
    I had the same issue but solved it by enabling spring on the Hinge Joint.
    The spring configuration that worked in my case was Sprint: 0.2, Damper: 0.15