2
0

BikeReset.cs 898 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. using Valve.VR;
  3. namespace Calibration
  4. {
  5. public class BikeReset : MonoBehaviour
  6. {
  7. public SteamVR_Action_Boolean resetPosition;
  8. private Vector3 initialPosition;
  9. private Quaternion initialRotation;
  10. private Transform bikeTransform;
  11. void Start()
  12. {
  13. bikeTransform = transform;
  14. initialPosition = bikeTransform.localPosition;
  15. initialRotation = bikeTransform.localRotation;
  16. resetPosition.AddOnStateUpListener(OnResetPosition, SteamVR_Input_Sources.Any);
  17. }
  18. private void OnResetPosition(SteamVR_Action_Boolean fromaction, SteamVR_Input_Sources fromsource)
  19. {
  20. Debug.Log("Resetting Bike Position and Rotation");
  21. bikeTransform.localPosition = initialPosition;
  22. bikeTransform.localRotation = initialRotation;
  23. }
  24. }
  25. }