BikeReset.cs 906 B

1234567891011121314151617181920212223242526272829
  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 Transform bikeTransform;
  9. private Vector3 initialPosition;
  10. private Quaternion initialRotation;
  11. private 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. }