BikeReset.cs 852 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Valve.VR;
  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. }