diff --git a/Assets/Scripts/FurnitureMover.cs b/Assets/Scripts/FurnitureMover.cs index 830d28e..743f38f 100644 --- a/Assets/Scripts/FurnitureMover.cs +++ b/Assets/Scripts/FurnitureMover.cs @@ -13,6 +13,9 @@ public class FurnitureMover : MonoBehaviour public SteamVR_Behaviour_Pose pose; public SteamVR_Action_Boolean interactWithUI = SteamVR_Input.GetBooleanAction("InteractUI"); + public SteamVR_Action_Boolean snapLeftAction = SteamVR_Input.GetBooleanAction("SnapTurnLeft"); + public SteamVR_Action_Boolean snapRightAction = SteamVR_Input.GetBooleanAction("SnapTurnRight"); + public LayerMask AutoPlacementEnvironmentMask; public GameObject pointer; @@ -23,6 +26,7 @@ public class FurnitureMover : MonoBehaviour public Color clickColor = Color.green; private SnapTurn _snapturn; + private Hand hand; private SnapTurn snapturn { get @@ -36,6 +40,7 @@ public class FurnitureMover : MonoBehaviour } private void Start() { + hand = GetComponent(); if (pose == null) pose = this.GetComponent(); if (pose == null) @@ -139,7 +144,35 @@ public class FurnitureMover : MonoBehaviour pointer.GetComponent().material.color = color; } pointer.transform.localPosition = new Vector3(0f, 0f, dist / 2f); + + + + + if(Grabbing != null && snapLeftAction != null && snapRightAction != null && snapLeftAction.activeBinding && snapRightAction.activeBinding) + { + + bool leftHandTurnLeft = snapLeftAction.GetStateDown(hand.handType); + bool rightHandTurnLeft = snapLeftAction.GetStateDown(hand.otherHand.handType); + + bool leftHandTurnRight = snapRightAction.GetStateDown(hand.handType); + bool rightHandTurnRight = snapRightAction.GetStateDown(hand.otherHand.handType); + + if (leftHandTurnLeft || rightHandTurnLeft) + { + RotateObject(-45); + } + else if (leftHandTurnRight || rightHandTurnRight) + { + RotateObject(45); + } + } } + + private void RotateObject(float angle) + { + Grabbing.gameObject.transform.eulerAngles += new Vector3(0, angle, 0); + } + public void GrabFurniture(GameObject furniture) { Catalog.Instance.GrabObject(furniture, gameObject.GetComponent());