Rotate an object with fixed point using controller in VR

1.9k Views Asked by At

I would like to have an object that has a fixed point and rotates based on controller movement in VR.

Here is what I want to implement

  1. The user grabs an object.
  2. The user pulls/pushes the object in any direction while grabbing.
  3. Based on the controller movement(pushing/pulling) the object rotates like a lever.
  4. Constraint: The object must never leave its position, it must stay fixed.

An illustration is shown in this video -> Rotation with fixed point

I am trying to implement this using Unity and VRTK.

1

There are 1 best solutions below

0
On

https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html

Only use transform.RotateAround() and the exact center position you want to rotate around and the first parameter. You can calculate the angle using Vector3.Angle and Transform.InverseTransformDirection.

This functionality is also already implemented in an example in the SteamVR SDK: https://assetstore.unity.com/packages/tools/integration/steamvr-plugin-32647