Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Oculus Vr hands inertia

Discussion in 'Physics' started by y0kkaboom, Mar 1, 2019.

  1. y0kkaboom

    y0kkaboom

    Joined:
    Oct 18, 2018
    Posts:
    18
    Okay so I'm currently working on a Vr project and I used Oculus Sample FrameWork in order to get the hands working.
    So I didn't write that part:
    When my character moves, the hands have inertia, like they are a bit late with any of the movement (just when I walk, when I move my hands alone no problem). And to be honest it's quite annoying.

    I found That:

    Code (CSharp):
    1.     // Hands follow the touch anchors by calling MovePosition each frame to reach the anchor.
    2.     // This is done instead of parenting to achieve workable physics. If you don't require physics on
    3.     // your hands or held objects, you may wish to switch to parenting.
    4.     void OnUpdatedAnchors()
    5.     {
    6.         Vector3 handPos = OVRInput.GetLocalControllerPosition(m_controller);
    7.         Quaternion handRot = OVRInput.GetLocalControllerRotation(m_controller);
    8.         Vector3 destPos = m_parentTransform.TransformPoint(m_anchorOffsetPosition + handPos);
    9.         Quaternion destRot = m_parentTransform.rotation * handRot * m_anchorOffsetRotation;
    10.         GetComponent<Rigidbody>().MovePosition(destPos);
    11.         GetComponent<Rigidbody>().MoveRotation(destRot);
    12.  
    13.         if (!m_parentHeldObject)
    14.         {
    15.             MoveGrabbedObject(destPos, destRot);
    16.         }
    17.         m_lastPos = transform.position;
    18.         m_lastRot = transform.rotation;
    19.  
    20.         float prevFlex = m_prevFlex;
    21.         // Update values from inputs
    22.         m_prevFlex = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller);
    23.  
    24.         CheckForGrabOrRelease(prevFlex);
    25.     }
    I'm quite sure the problem comes from here...
    But to be honest I have no idea how to switch to parenting because if I do it via the editor, My hands are just elsewhere, and not even moving accordingly but far...
    If you Have any ideas I would be super glade ^^
    Thank you very much!
    Up!
     
    Last edited: Mar 7, 2019