playMaker

Author Topic: Setting up VR Door with hinges to follow hand  (Read 2109 times)

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 139
Setting up VR Door with hinges to follow hand
« on: November 21, 2017, 05:32:17 PM »
Hi, Playmakers!

I have a door on a Hinge Joint that has limited rotation (0 to 90).

I want to grab the handle of the door, and have it rotate on the Hinge to follow the controller. When the handle is released, I want the door to close itself based on the Spring settings in the Hinge Joint.

I've got a trigger volume that tests whether the handle is 'gripped', which works.

However, I have not been able to find a way to make the door rotate to follow the controller while respecting the limits of the hinge.

I tried a 'LookAt', which works in a way, but it does not respect the Hinge (meaning it will rotate past the limits set in the Hinge Joint).

I'm on the Rift currently, but I want to make something that will work with Vive as well.

Any suggestions?

Thanks, and I'll reply with results from any suggestions!

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Setting up VR Door with hinges to follow hand
« Reply #1 on: November 22, 2017, 11:37:53 AM »
Hi there ToxicFrog.

Most people here will advise you to try VRTK with the Playmaker actions, however i had some problems with VRTK so i dicided to make my own full physics driven interaction system.

So if you just want to use Playmaker, this is what you'll want to do. (there are other ways but this works the best with physics)

Make sure your hands/controllers have a rigidbody on them with gravity/kinematic set to off.

Then integrate the following actions in your door/interactons script to make the door follow the hand/controller.

  • Get Position: of your controller in world space and save the Vector3
  • Get Position: of your door handle in world space and save the Vector3
  • Vector3 Operator: Subtract your ControllerPosition from your HandlePosition and save as Vector3
  • Vector3 Multiply: Multiply that Vector3 with a float (lets say 50/this will control the speed at which the door follows the controller)
  • Set Velocity: On your door/rigidbody in world space using the Vector3 you just made.
(Check Every Frame on all actions)

That should work depending on how your interaction Fsm is setup.

If you have any problems with that just let me know.
« Last Edit: November 22, 2017, 11:54:19 AM by LordHorusNL »

ToxicFrog

  • Beta Group
  • Full Member
  • *
  • Posts: 139
Re: Setting up VR Door with hinges to follow hand
« Reply #2 on: November 22, 2017, 03:26:52 PM »
Thanks, LordHorus!
I managed to get it working as intended with VRTK this morning. So far, so good. But, if I encounter any issues I will try your method next.
I appreciate your help!

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Setting up VR Door with hinges to follow hand
« Reply #3 on: November 22, 2017, 04:15:13 PM »
Good to hear!

VRTK will do just fine for most games.