*Update: This question has been superceded as the interface approach taken has been fully revised – a video and new code here: Vector3 question: How to know right axis when using pinch punch gestures to scale object in virtual reality? - Questions & Answers - Unity Discussions *
I would like the user (using a Vive) to adjust a given held transform’s localScale by using the other hand’s relative motion during a trigger press. For instance, if the left hand as below makes the direction meaning up/ grow (where up, right and forward = increase, and reverse for shrinking), then I would like the localScale of the right pictured cuboid to grow alongside [a], as that’s currently closest to the intended up. However, since the cuboid transform is already rotated, how do I find out at which of x/y/z of the localScale should scale as per intended direction?
Here’s a non-working example code try:
Vector3 rotatedPoint = RotatePointAroundPivot(currentHandTransform.position, positionEmptyClickStarted, -otherHandTransform.eulerAngles);
Vector3 differenceVector = rotatedPoint - positionEmptyClickStarted;
otherHandTransform.localScale = otherHandTransformStartScale + differenceVector;
// snip
Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles) {
Vector3 dir = point - pivot;
dir = Quaternion.Euler(angles) * dir;
point = dir + pivot;
return point;
}
Thanks for any help!