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

Question Oculus Rift, get delta location of hand in world space

Discussion in 'VR' started by bigvalthoss, Feb 16, 2021.

  1. bigvalthoss

    bigvalthoss

    Joined:
    May 26, 2020
    Posts:
    23
    Hello, I am doing something that recognizes how far you've moved your hand after you've pressed the left index trigger. Basically, if you press the trigger, then move your hand it records the delta. Next, based on whichever is the largest (delta x, y or x). it moves an object in that direction. However, It seems I need to orient based on world space and I don't exactly know how to change from local to world. Here is what I have:

    // Trigger press location
    TriggerPressLocation = transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch));

    // then, in the update clause, while the trigger is being pressed:
    Vector3 CR = transform.TransformPoint(OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch));
    deltaLocation = new Vector3(CR.x - TriggerPressLocation.x, CR.y - TriggerPressLocation.y, CR.z - TriggerPressLocation.z);
     
  2. bigvalthoss

    bigvalthoss

    Joined:
    May 26, 2020
    Posts:
    23
    does the transform change based on what object it is attached to? If so how do I get world space (or something that amounts to the same thing)
     
  3. bigvalthoss

    bigvalthoss

    Joined:
    May 26, 2020
    Posts:
    23