generated from VR-Sexe/Unity3DTemplate
Furniture turn
This commit is contained in:
parent
7fc663894c
commit
d453344ba6
@ -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<Hand>();
|
||||
if (pose == null)
|
||||
pose = this.GetComponent<SteamVR_Behaviour_Pose>();
|
||||
if (pose == null)
|
||||
@ -139,7 +144,35 @@ public class FurnitureMover : MonoBehaviour
|
||||
pointer.GetComponent<MeshRenderer>().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<Hand>());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user