how to apply angular displacement from one object to another?

Hi,

I’m trying to apply the rotation of the hand with Oculus touch to a given object, but only when the player holds the right buttons. Also, I’m not trying to mirror the hand rotation, but rather apply the angular displacement to the object current rotation, my objective is to simulate a “grab and rotate” effect.

I’m just noobie in the world of 3d math, but following the theory here is what I got:

using UnityEngine;

public class FollowRotation : MonoBehaviour
{
    private Quaternion _previousHandRotation;

    // Use this for initialization
    void Start()
    {
        _previousHandRotation = OVRInput.GetLocalControllerRotation (OVRInput.Controller.RTouch);

    }

    private void Update()
    {
        if (OVRInput.Get(OVRInput.Button.SecondaryIndexTrigger) && OVRInput.Get(OVRInput.Button.SecondaryHandTrigger))
        {
            Quaternion currentHandRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
            Quaternion handAngularDisplacement = currentHandRotation * Quaternion.Inverse(_previousHandRotation);
            Quaternion newRotation = handAngularDisplacement * transform.rotation;
            transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime);
        }
        _previousHandRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);

    }
}

But I’m definetly missing something because I haven’t been able to make it work. Any help or direction would be highly appriciate it!

That looks correct, but I’d drop the Slerp. Just set transform.rotation to newRotation.