Question by 
               ruchirnaphade · Nov 12, 2020 at 02:59 PM · 
                rotationunity4.3  
              
 
              Rotate 3arrow using two hands (HoloLens2)
I am instantiating a Arrow prefab which has rigidbody for collision detection. I want to rotate this arrow using two hands. I dont want to use MRTK's Object manipulator script to do this. I want to create a script which can be used for rotation. I have tried many different techniques for rotating the object but not able to do it. Can someone please tell me how to do it?
RotationScript:
 public class ArrowRotate : MonoBehaviour, IMixedRealityPointerHandler
 {
     private IMixedRealityHand handOne;
     private IMixedRealityHand handTwo;
     private IMixedRealityPointer pointerOne;
     private IMixedRealityPointer pointerTwo;
     private bool isPointerDown;
     private Vector3 startPoint;
     private Vector3 endPoint;
 
     private void Update()
     {
         if (handOne != null && handTwo != null)
         {
             if (handOne.TryGetJoint(TrackedHandJoint.IndexTip, out MixedRealityPose jointPoseOne) && handTwo.TryGetJoint(TrackedHandJoint.IndexTip, out MixedRealityPose jointPoseTwo))
             {
                 Debug.Log("ok");
             }
         }
     }
 
     void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData eventData)
     {
         if (handOne == null)
         {
             pointerOne = eventData.Pointer as IMixedRealityPointer;
             handOne = eventData.Pointer.Controller as IMixedRealityHand;
             startPoint = pointerOne.Position; // using this point to rotate the object
         }
 
 
 
     }
 
     void IMixedRealityPointerHandler.OnPointerDragged(MixedRealityPointerEventData eventData)
     {
         if (!eventData.Pointer.Controller.Equals(handOne))
         {
             pointerTwo = eventData.Pointer as IMixedRealityPointer;
             handTwo = eventData.Pointer.Controller as IMixedRealityHand;
             endPoint = pointerTwo.Position;
 
             Vector3 rotationVector = startPoint - endPoint;
             Quaternion rotationInfo = new Quaternion();
             rotationInfo.SetLookRotation(rotationVector);
             rotationInfo *= Quaternion.Euler(90, 0, 0);
             this.gameObject.transform.rotation = rotationInfo;
         }
     }
 
     void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventData)
     {
     }
 
     void IMixedRealityPointerHandler.OnPointerClicked(MixedRealityPointerEventData eventData)
     {
         //throw new System.NotImplementedException();
     }
 
     private void OnEnable()
     {
         CoreServices.InputSystem?.RegisterHandler<IMixedRealityPointerHandler>(this);
     }
 
     private void OnDisable()
     {
         CoreServices.InputSystem?.UnregisterHandler<IMixedRealityPointerHandler>(this);
     }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Rotate camera on collision of character 1 Answer
Cancel out the steering rotation returned from a wheel colliders .GetWorldPose(out pos, out rot); 1 Answer
Space/Aircraft rotation 0 Answers
Camera Controller script as a child object,Camera Control as a Child Object for my Player 0 Answers
Object Rotation With Touch 0 Answers