Skip to content

Commit

Permalink
Fix dialing wand issues
Browse files Browse the repository at this point in the history
-fix rotation and offset for left hand
-make position consistent
  • Loading branch information
JonnyOThan committed Feb 16, 2023
1 parent 14f698d commit 262279e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions KerbalVR_Mod/KerbalVR/InteractionSystem/KerbalVR_Hand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public Vector3 GripPosition

// default cylinder is 2 units tall and 1 unit in diameter
static Vector3 x_wandScale = new Vector3(0.008f, 0.1f, 0.008f);
static Vector3 x_wandRotation = new Vector3(90, 90, 0);
static Vector3 x_wandPosition = new Vector3(-0.05f, 0, 0);
static Vector3 x_wandRotation = new Vector3(0, 0, 0);
static Vector3 x_wandPosition = new Vector3(0.04f, -0.05f, 0.04f);

GameObject wandObject;

Expand All @@ -83,11 +83,20 @@ internal void SummonDialingWand()
wandObject = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
Component.Destroy(wandObject.GetComponent<Collider>());

wandObject.transform.SetParent(pinchCollider.transform, false);
Vector3 wandRotation = x_wandRotation;
Vector3 wandPosition = x_wandPosition;

if (handType == SteamVR_Input_Sources.LeftHand)
{
wandRotation.x = -wandRotation.x;
wandPosition.x = -wandPosition.x;
}

wandObject.transform.SetParent(palmCollider.transform, false);
wandObject.layer = 20;
wandObject.transform.localScale = x_wandScale;
wandObject.transform.localRotation = Quaternion.Euler(x_wandRotation);
wandObject.transform.localPosition = x_wandPosition;
wandObject.transform.localRotation = Quaternion.Euler(wandRotation);
wandObject.transform.localPosition = wandPosition;

fingertipCollider.transform.SetParent(wandObject.transform, false);
fingertipCollider.transform.localPosition = new Vector3(0, -1, 0);
Expand Down

0 comments on commit 262279e

Please sign in to comment.