Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
JohnnyLincoln's avatar
JohnnyLincoln
Honored Guest
5 years ago
Solved

Constrain grabbable object motion in Unity

I want to open a window by grabbing it and pulling open up and down. How can I constrain the movement of the window using the Oculus's Unity package?

  • baroquedub's avatar
    baroquedub
    5 years ago

    If you're using OVRGrabbable instead of just interacting with a rigidbody then I think the classic workaround is to grab an invisible object that then drives the movement of your window. It's the technique described in this video for a door but a window would be the same. https://www.youtube.com/watch?v=3cJ_uq1m-dg&t=129s

3 Replies

Replies have been turned off for this discussion
  • The constrain isn't really anything to do with The Oculus SDK, it's a Unity thing. If your window is a physics object with a rigidbody you can constrain the X, Y, Z movement on that component by using the Freeze Position tick boxes: https://docs.unity3d.com/Manual/class-Rigidbody.html (you'll probably also want to freeze rotations)

    • JohnnyLincoln's avatar
      JohnnyLincoln
      Honored Guest

      Thanks for the response. I tried constraining the movement in that way but the  OVR Grabbable script  seems to override it.

      • baroquedub's avatar
        baroquedub
        MVP

        If you're using OVRGrabbable instead of just interacting with a rigidbody then I think the classic workaround is to grab an invisible object that then drives the movement of your window. It's the technique described in this video for a door but a window would be the same. https://www.youtube.com/watch?v=3cJ_uq1m-dg&t=129s