void Update() { if (grab == GrabState.Both) { float scale = Vector3.Distance(leftController.transform.position, rightController.transform.position) / refDist; if (resizable != null) { resizable.SetScale(refScale * scale); } if (movable != null) { Vector3 displacement = (rightController.transform.position - leftController.transform.position).normalized; Vector3 controllersUp = (leftController.transform.up + rightController.transform.up).normalized; Quaternion quat = Quaternion.FromToRotation(refControllers, displacement) * Quaternion.FromToRotation(refUp, controllersUp); movable.SetPosition(quat * (refPos - refCenter) * scale + center); movable.SetRotation(quat * refRot); } } }