Skip to main content
New Participant
November 13, 2021
Solved

Constrain grabbable object motion in Unity

  • November 13, 2021
  • 3 replies
  • 3232 views

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?

    This topic has been closed for replies.
    Best answer by baroquedub

    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

    Honored Contributor
    November 14, 2021

    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)

    New Participant
    November 14, 2021

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

    Honored Contributor
    November 15, 2021

    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